Years ago I wrote the Sorting mini-howto, currently at
http://www.amk.ca/python/howto/sorting/sorting.html
I've had various people thank me for that, in person and
through email.
It's rather out of date now given the decorate-sort-undecorate
option and 'sorted' functions in Python 2.4. Hmmm,
I wrote:
> Years ago I wrote the Sorting mini-howto, currently at
>
> http://www.amk.ca/python/howto/sorting/sorting.html
Thanks to amk it's now on the Wiki at
http://wiki.python.org/moin/HowTo/Sorting
so feel free to update it directly.
Andrew
"It's me" wrote:
> Here's a NDFA for your text:
>
>b 0 1-9 a-Z , . + - ' " \n
> S0: S0 E E S1 E E E S3 E S2 E
> S1: T1 E E S1 E E E E E E T1
> S2: S2 E E S2 E E E E E T2 E
> S3: T3 E E S3 E E E E E E T3
Now if I only had an NDFA for parsing that syntax...
Craig Ringer wrote:
> My first thought would be to express your 'A and B' regex as:
>
> (A.*B)|(B.*A)
>
> with whatever padding, etc, is necessary. You can even substitute in the
> sub-regex for A and B to avoid writing them out twice.
That won't work because of overlaps. Consider
barkeep
w
Mike Meyer:
> Trivia question: Name the second most powerfull country on earth not
> using the metric system for everything.
The UK?
Before going there I thought they were a fully metric country.
But I saw weather reports in degrees F, distances in yards
and miles, and of course pints of beer.
Me
(BTW, it needs to be 1 .. 12 not 1..12 because 1. will be interpreted
as the floating point value "1.0".)<
Steve Holden:
> Indeed, but if ".." is defined as an acceptable token then there's
> nothing to stop a strict LL(1) parser from disambiguating the cases in
> question. "Token"
Bengt Richter:
> But it does look ahead to recognize += (i.e., it doesn't generate two
> successive also-legal tokens of '+' and '=')
> so it seems it should be a simple fix.
But that works precisely because of the greedy nature of tokenization.
Given "a+=2" the longest token it finds first is "a"
Paul Rubin:
> Lately there are people trying to program PC's to
> simulate the Lisp hardware and to get the Lisp Machine software
> released (now that the commercial market for it has long since dried
> up). However, both of those projects have a ways to go.
There's a video of someone demoing how
Paul Rubin wrote:
> [Type checking] should be left on. Leaving it in for development
> and turning it off for production is like wearing a parachute
> during ground training and taking it off once you're in the air.
Why isn't it like practicing the trapeze with a net but
going without a net when
Michael Hoffman wrote:
> Having path descend from str/unicode is extremely useful since I can
> then pass a path object to any function someone else wrote without
> having to worry about whether they were checking for basestring. I think
> there is a widely used pattern of accepting either a bas
Duncan Booth wrote:
> Personally I think the concept of a specific path type is a good one, but
> subclassing string just cries out to me as the wrong thing to do.
I disagree. I've tried using a class which wasn't derived from
a basestring and kept running into places where it didn't work well.
George Sakkis wrote:
> You're right, conceptually a path
> HAS_A string description, not IS_A string, so from a pure OO point of
> view, it should not inherit string.
How did you decide it's "has-a" vs. "is-a"?
All C calls use a "char *" for filenames and paths,
meaning the C model file for the f
François Pinard wrote:
> There is no strong reason to use one and avoid the other. Yet, while
> representing strings, Python itself has a _preference_ for single
> quotes.
I use "double quoted strings" in almost all cases because I
think it's easier to see than 'single quoted quotes'.
Joshua Ginsberg wrote:
> >>> dir(ifs)
> ['__doc__', '__init__', '__iter__', '__module__', '__repr__', 'close',
> 'fileno', 'fp', 'geturl', 'headers', 'info', 'next', 'read',
> 'readline', 'readlines', 'url']
>
> Yep. But what about in my code? I modify my code to print dir(ifs)
> before cr
Dr. Who wrote:
> Well, I finally managed to solve it myself by looking at some code.
> The solution in Python is a little non-intuitive but this is how to get
> it:
>
> while 1:
> line = stdout.readline()
> if not line:
> break
> print 'LINE:', line,
>
> If anyone can do it th
George Sakkis wrote:
> Bringing up how C models files (or anything else other than primitive types
> for that matter) is not a particularly strong argument in a discussion on
> OO design ;-)
While I have worked with C libraries which had a well-developed
OO-like interface, I take your point.
Stil
George Sakkis wrote:
> That's why phone numbers would be a subset of integers, i.e. not every
> integer would correspond to a valid number, but with the exception of
> numbers starting with zeros, all valid numbers would be an integers.
But it's that exception which violates the LSP.
With numbers
Andy wrote:
> How can you unit test nested functions?
I can't think of a good way. When I write a nested function it's because
the function uses variables from the scope of the function in which it's
embedded, which means it makes little sense to test it independent of the
larger function.
My te
Reinhold Birkenfeld wrote:
> Okay. While a path has its clear use cases and those don't need above methods,
> it may be that some brain-dead functions needs them.
"brain-dead"?
Consider this code, which I think is not atypical.
import sys
def _read_file(filename):
if filename == "-":
# Ca
> Reinhold Birkenfeld wrote:
>> Current change:
>>
>> * Add base() method for converting to str/unicode.
Now that [:] slicing works, and returns a string,
another way to convert from path.Path to str/unicode
is path[:]
Andrew
[EMAIL
> [EMAIL PROTECTED] wrote:
>> Well, it's what (R)DBMS are for, but plain files are not.
Steven D'Aprano wrote:
> This isn't 1970, users expect more from professional
> programs than "keep your fingers crossed that nothing
> bad will happen". That's why applications have multiple
> levels of und
David Isaac wrote:
> I have been generally open to the proposal that list comprehensions
> should replace 'map', but I ran into a need for something like
> map(None,x,y)
> when len(x)>len(y). I cannot it seems use 'zip' because I'll lose
> info from x. How do I do this as a list comprehension? (O
Steven Bethard wrote:
> Here's one possible solution:
>
> py> import itertools as it
> py> def zipfill(*lists):
> ... max_len = max(len(lst) for lst in lists)
A limitation to this is the need to iterate over the
lists twice, which might not be possible if one of them
is a file iterator.
Here's
Me:
> Here's a clever, though not (in my opinion) elegant solution
...
> This seems a bit more elegant, though the "replace" dictionary is
> still a bit of a hack
Here's the direct approach without using itertools. Each list is
iterated over only once. No test against a sequence element is ever
Christopher Subich wrote:
> My naive solution:
...
>for i in ilist:
> try:
> g = i.next()
> count += 1
> except StopIteration: # End of iter
> g = None
...
What I didn't like about this was the extra overhead of all
the StopIt
Bryan wrote:
> Why does os._exit called from a Python Timer kill the whole process while
> sys.exit does not? On Suse.
os._exit calls the C function _exit() which does an immediate program
termination. See for example
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/_e
Peter Otten wrote:
> Combining your "clever" and your "elegant" approach to something fast
> (though I'm not entirely confident it's correct):
>
> def fillzip(*seqs):
> def done_iter(done=[len(seqs)]):
> done[0] -= 1
> if not done[0]:
> return
> while 1:
>
Me:
>> Could make it one line shorter with
>
>> from itertools import chain, izip, repeat
>> def fillzip(*seqs):
>> def done_iter(done=[len(seqs)]):
>> done[0] -= 1
>> if not done[0]:
>> return []
>> return repeat(None)
>> seqs = [chain(seq, done_iter()
Scott David Daniels wrote:
> Can I play too? How about:
Sweet!
Andrew
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
> Seems my description didn't convince you. So here's an example:
Got it. In my test case the longest element happened to be the last
one, which is why it didn't catch the problem.
Thanks.
Andrew
[EMAIL PROTECTED
Peter Hansen wrote:
> A scattered assortment of module-level global function names, and
> builtins such as open(), make it extraordinarily difficult to do
> effective and efficient automated testing with "mock" objects.
I have been able to do this by inserting my own module-scope function
that i
Coming in a few days late to this one ...
Skip
> See if my latscii codec works for you:
>
> http://www.musi-cal.com/~skip/python/latscii.py
for another variation see that "Unicode Hammer" at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/251871
It doesn't do the registry hooks th
On Mon, 28 Feb 2005 15:50:22 -0500, Dan Sommers wrote:
> The reason their code is so inflexible is that they've filled their
> classes with boiler plate get/set methods.
>
> Why do users of classes need such access anyway? If my class performs
> useful functions and returns useful results, no use
On Mon, 28 Feb 2005 18:25:51 -0500, Douglas Alan wrote:
> While writing a generator, I was just thinking how Python needs a
> "yield_all" statement. With the help of Google, I found a pre-existing
> discussion on this from a while back in the Lightweight Languages
> mailing list. I'll repost it h
Me:
>> What's wrong with the use of attributes in this case and how
>> would you write your interface?
Dan Sommers:
> I think I'd add a change_temperature_to method that accepts the target
> temperature and some sort of timing information, depending on how the
> rest of the program and/or thread i
Mark Rowe wrote:
> A better method would be something along the lines of:
>
> plugin = __import__(pluginName)
> plugin.someMethod()
In the one time I did a plugin architecture I found that
state = ... set up intial state for my program ...
...
plugin = __import__(pluginName)
plugin.someMethod
> On 3 Mar 2005 11:06:58 -0800, [EMAIL PROTECTED] wrote:
>> How did we ever live without Google?
On Thu, 03 Mar 2005 21:48:27 +0100, BOOGIEMAN wrote:
> We used Yahoo (and still using it)
Altavista. Lycos.
Veronica on gopher. Archie on telnet.
Lists of anonymous ftp sites (like
http://thprox
Torsten Bronger wrote:
> Accordings to Stroustrup's C++ book, the only good reason for goto
> statements in a language is to have it in computer-generated code.
I've needed goto statements when translating old code written
with gotos.
> Most gotos are disguised function calls, so
> just copy the
beliavsky wrote:
> Goto is useful in breaking out of a nested loop and when there is a
> clean-up section of a function that should be executed for various
> error conditions.
But much less useful in languages like Python which have exception
handling.
At rare times I've needed something like
fo
Paul McGuire wrote:
> At the risk of beating this into the Pythonic ground, here is a
> generator version which collapses the original nested loop into a
> single loop, so that break works just fine:
Indeed. For some things I'm still in the pre-generator days of
Python. If I worked at it I think
Tim Jarman wrote:
OK, I'm an arts graduate[1] so this is probably a really stupid
question, but what kind(s) of science would be non-experimental?
Astronomy. Archaeology. Paleontology. Seismology. Cosmic ray
research.
There have been a few experiments in environmental science, like
tenting a s
I've been looking for a decent 3D plotting library with support
for user selection that works under OpenGl, preferable with wxPython.
For this first project I need to do a 3D scatter plot with
different colors and glyphs (spheres, crosses, etc.) for the points.
The axes will be labeled and I would
JanC:
> That person might be a student in some third-world country...
Then think of the extra incentive to provide useful answers.
Also, Eric had pointed out that payment included "money,
sex, chocolate" and other non-monetary possibilities.
Personally I think it'll be hard to put a monetary mi
Robert Kern:
> Here are the instructions that I posted to the PythonMac mailing list a
> while ago:
Thanks. I am able to build and install VTK as per your instructions,
except that I don't see an option for
> Toggle VTK_USE_GL2PS on (useful for printing).
Once installed the Examples/Rendering/
mother, born a Hanson. Scandinavian heritage?
Det vet jag inte. :)
Sadly, none of them know Python. And my g'grandfather was
German in case you were wondering.
Andrew Dalke
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Adam DePrince
> During the 1980's BASIC was the language to embedd into the ROM's of the
> computers of the day. This was in a misguided effort to make computers
> understandable to their target audience. The goal of the day was to
> build a system that a manager would want to buy; it was believ
[EMAIL PROTECTED] wrote:
> Now wait a minute, shouldn't that be...
>
> PLAY "CGFED>CChttp://mail.python.org/mailman/listinfo/python-list
Adam DePrince wrote:
> Sure you could have. There is nothing I hate more than the dumbing down
> of technology for the sake of families with children. Having kids
> doesn't make you dumb, it only makes you feel that way when you realize
> how quickly your children's technical prowess with outstri
Dennis Lee Bieber wrote:
> Ah, but you said "standard" module for Python... The
> graphics/sound extensions on your TI 99/4A were not "standard" BASIC...
I assume by "standard" you mean some sort of formal standard,
like ANSI Basic or ISO C? If so, well, there's no "standard" Python.
What
Dennis Lee Bieber wrote:
>for the A above middle-C... The other A's would be: 55,
> 110, 220, (440), 880, 1760...
And for a while I had the first few digits of the 12th root
of 2 memorized.
> Granted... But it seemed the starting complaint was that Python
> -- a language that tries
Keith Dart wrote:
> Are you saying that if you write,
> full time, code for "production", that fluency will decrease?
To add to Aahz's response, there are some corners of Python
I learned once and decided shouldn't be in production code
because it would be too hard to maintain. 'reduce' is one o
/F
> import random, winsound
Now if it only worked for my mac ...
:)
Andrew
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Jan Dries
> If you just want to play notes, you could look at MIDI.
I've been thinking about how to answer this and came
to the conclusion I can't.
I was talking about my early experiences in learning
to program as a teenager in the early 1980s. I had
fun messing around with sound, both to play
Jan Dries:
> The funny thing is, for me, MIDI is dead old. One of my first computers,
> back in 1986, was an Atari ST. It came equiped with a MIDI port.
While the time I was talking about was some 3 or 4 years
before 1986.
> I seem to remember that even then we still had to rely on a keyboard
Terry Reedy wrote:
> As far as I know, apply(func, args) is exactly equivalent to func(*args).
After playing around a bit I did find one difference in
the errors they can create.
>>> def count():
... yield 1
...
>>> apply(f, count())
Traceback (most recent call last):
File "", line 1, in ?
T
Benji York wrote:
> They do two different things. I think you have a spurious * in the call
> to apply. The apply above is equivalent to
D'oh! This cold has definitely made me error prone the last
couple of days. Yesterday I managed to leave my cell phone
in my pants pocket along with a coupl
Terry Reedy wrote:
> Ok, add 'assuming that func and args are a valid callable and sequence
> respectively.' Error messages are not part of the specs, and may change
> for the same code from version to version.
While true, the difference in error messages suggests that the
two approaches use sl
Nick Coghlan wrote:
> And you're right, there is a behavioural difference - apply() expects a real
> sequence, whereas the extended function call syntax accepts any iterable.
>
> However, there's also a bug in your demo code:
I guess I must be getting over this cold -- I'm only 1/2 wrong
this ti
Andrew Koenig:
> If d is a dict and t1 and t2 are tuples, and t1 == t2, then d[t1] and d[t2]
> are the same element.
So long as the elements of t1 and t2 are well-behaved.
>>> class Spam:
... def __hash__(self):
... return id(self)
... def __eq__(self, other):
... return True
...
>>
Steve Holden wrote:
> If this isn't spam I'll eat my hat. How many other irrelevant newsgroups
> has this been sent to? Headers follow for abuse tracking and retribution.
More precisely, the email is from a marketer in Pakistan.
http://www.pid.org.pk/resume.html
Note the lack of programming exp
bearophileHUGS:
[on Python's O(n) list insertion/deletion) at any place other than tail
> (My hypothesis: to keep list implementation a bit simpler, to avoid
> wasting memory for the head buffer, and to keep them a little faster,
> avoiding the use of the skip index S).
Add its relative infrequent
Paul Rubin wrote:
> ".." just becomes an operator like + or whatever, which you can define
> in your class definition:
>
> class MyClass:
>def __dotdot__(self, other):
> return xrange(self.whatsit(), other.whatsit())
>
> The .. operation is required to return an iterator.
A
Bengt Richter:
> OTOH, there is precedent in e.g. fortran (IIRC) for named operators of the
> form .XX. -- e.g., .GE. for >= so maybe there could be room for both.
> Hm, you could make
>
> x .infix. y
> x .op1. y .op2. z => op2(op1(x, y), z)
The problem being that that's already legal s
Maurice LING wrote:
> That's almost like asking which way of cooking chicken is the best?
> steam, fried, stew, roast?
BBQ'ed of course.
I believe that fits your point. :)
Andrew
[EMAIL PROTECTED]
--
http://mail.python.org/mailma
Is there an author index for the new version of the
Python cookbook? As a contributor I got my comp version
delivered today and my ego wanted some gratification.
I couldn't find my entries.
Andrew
[EMAIL PROTECTED]
--
http://mail.p
Kane wrote:
> I ran into a similar situation with a massive directory of PIL
> generated images (around 10k). No problems on the filesystem/Python
> side of things but other tools (most noteably 'ls') don't cope very
> well.
My experience suggests that 'ls' has a lousy sort routine or
that it tak
Bryan wrote:
> at pycon, several mac users were using a collaborative text editor where each
> user's text background color was a different color as they edited the same
> document at the same time while they took notes during the lectures. does
> anyone know the name of that program?
SubEth
Steve wrote:
> [an anecdote on distinguishing l1 and 11]
> What are some of other people's favourite tips for
> avoiding bugs in the first place, as opposed to finding
> them once you know they are there?
There's a good book on this topic - Writing Solid Code.
A
Grant Edwards wrote:
> For large files, something like this is probably a better idea:
Or with the little-used shutil module, and keeping your
nomenclature and block size of 65536
import shutil
fout = file('C', 'wb')
for n in ['A', 'B']:
fin = file(n, 'rb')
shutil.copyfileobj(fin, fout, 65536
In searching I find there several different ways to
connect to an Oracle server on MS Windows:
mxODBC - http://www.egenix.com/files/python/mxODBC.html
built on top of the ODBC drivers for a given database
DCOracle2 - http://www.zope.org/Members/matt/dco2/
last update is 1.3 beta relea
runes wrote:
> You should avoid the "a" + "b" + "c" -kind of concatenation. As strings
> at immutable in Python you actually makes copies all the time and it's
> slow!
The OP wrote
print "pet" + "#" + num_pets
(properly str(num_pets) )
You recommended the "alternative used in Steven Bethard
Derek Basch wrote:
> Interesting stuff Andrew. I do generally avoid string concantination
> for the reason listed in the Python Performance Tips but your analysis
> kinda puts that in question.
Thanks.
It was interesting for me to. I hadn't looked at the implementation
for string % before and wa
Michael Spencer wrote:
> I have wrapped up my current understanding in the following class:
I see you assume that only \w+ can fit inside of a %()
in a format string. The actual Python code allows anything
up to the balanced closed parens.
>>> class Show:
... def __getitem__(self, text):
...
A while back I asked about which Oracle client to use for
MS Windows. Turns out I also needed one for unix so I followed
people's advice and installed cx_Oracle.
I want to execute a query with an "IN" in the WHERE clause
and with the parameter taken from a Python variable. That
is, I wanted some
A few days ago Tom Mortimer wrote:
> A quick question - can anyone tell me how to interpret negative time
> values in pstats.Stats.print_stats() output?
See http://docs.python.org/lib/profile-limits.html
After the profiler is calibrated, it will be more accurate (in a least
square sense), but
A few days ago stephan wrote:
> Im am using PyRun_SimpleString() inside a BCB 5.0 GUI app
> on win32.
Never used it so can only offer a suggestion.
> For this I have a button called "stop", and when
> the user executes it, I generate an exeption by
> calling:
> PyRun_SimpleString("raise Keyboard
praba kar wrote:
> I want to know whether Python is compiler language
> or interpreted language. If Python is interpreter
> language why compilation is there.
That distinction is implementation dependent and
not an aspect of the language. How would that knowledge
affect your decisions or thought
[EMAIL PROTECTED] wrote:
> Thank you, it works, but I guess not all the way:
> but I need to remove the first - between 18:20:42 and 0.024329 but not
> the others.
Read the documentation for the string methods.
http://docs.python.org/lib/string-methods.html
replace(old, new[, count])
Ret
> Jeremy Bowers wrote:
>> No matter how you slice it, this is not a Python problem, this is an
>> intense voice recognition algorithm problem that would make a good
>> PhD thesis.
Qiangning Hong wrote:
> No, my goal is nothing relative to voice recognition. Sorry that I
> haven't described my que
Paul Rubin wrote:
> Let's say you have a SocketServer with the threading mix-in and you
> run serve_forever on it. How can you shut it down, or rather, how can
> it even shut itself down?
I looked at CherryPy's server because I know it uses Python's
BaseHTTPServer which is derived from SocketSer
Glenn Pierce wrote:
> if (!PyArg_ParseTuple(args, "isi", &format, filename, &flags))
> return NULL;
Shouldn't that be &filename ? See
http://docs.python.org/ext/parseTuple.html
for examples.
> dib = FreeImage_Load(format, filename, flags);
> Also I have little Ide
After I gave a reference to CherryPy's threaded SocketServer-based
http server code Paul Rubin followed up:
> Well, ok, so the worker threads stop. How do you get the listener
> thread to stop, since it's blocked waiting for a new connection to arrive?
I don't know the code well enough. You migh
infidel wrote:
> Something like this might work for you:
>
ids= ['D102', 'D103', 'D107', 'D108']
in_clause = ', '.join([':id%d' % x for x in xrange(len(ids))])
sql = "select * from tablename where id in (%s)" % in_clause
import cx_Oracle as ora
con = ora.connect('foo/[EMA
infidel wrote:
> I think perhaps you are asking for something that the OCI doesn't
> provide.
But it doesn't need to be supported by the OCI.
> And really, it all boils down to the list comprehension:
>
> in_clause = ', '.join([':id%d' % x for x in xrange(len(ids))])
And why can't the equivalen
Steve Holden wrote:
> Do you think this is a DB-API 3-ish kind of a thing, or would it layer
> over DB-API 2 in a relatively platform-independent manner?
...
> but-you-may-know-better-ly y'rs - steve
I am a tyro at this. I had to find some tutorials on SQL
to learn there even was an IN cla
Mike Meyer wrote:
> Someone want to tell me the procedure for submitting FAQ entries, so I
> can do that for this?
You mean more than what already exists at
http://www.python.org/doc/faq/general.html#why-are-floating-point-calculations-so-inaccurate
which has a link to an even more detailed ch
andrea.gavana wrote:
> If I simplify the problem, suppose I have 2 lists like:
>
> a = range(10)
> b = range(20,30)
>
> What I would like to have, is a "union" of the 2 list in a single tuple. In
> other words (Python words...):
>
> c = (0, 20, 1, 21, 2, 22, 3, 23, 4, 24, 5, 25, .
The 'yiel
Daniel Dittmar wrote:
> Possible workarounds:
...
> - create a class for this purpose. Statement are created on the fly, but
> with placeholders so you don't run into the SQL Injection problem. As
> it's an object, you could cache these generated statements base on the
> size of the list
> It
Delaney, Timothy C (Timothy) wrote:
> Remember, finalisers are not called when Python exits. So if you don't
> explicitly close the file you are *writing* to, it may not be flushed
> before being closed (by the OS because the process no longer exists).
Wrong.
% python
Python 2.3 (#1, Sep 13 2003,
Steven Bethard wrote:
> Well one reason might be that it's easy to convert from an object's
> attributes to a dict, while it's hard to go the other direction:
...
> py> options['x'], options['y']
> ('spam', 42)
> py> o = ??? # convert to object???
> ...
> py> o.x, o.y
> ('spam', 42)
"hard" == "
Paul Rubin wrote:
> Yes, there are several Python compilers already
...
> It's true that CPython doesn't have a compiler and that's a serious
> deficiency. A lot of Python language features don't play that well
> with compilation, and that's often unnecessary. So I hope the baseline
> implem
Timothy Smith wrote:
> ok what i am seeing is impossible.
> i DELETED the file from my webserver, uploaded the new one. when my app
> logs in it checks the file, if it's changed it downloads it. the
> impossible part, is that on my pc is downloading the OLD file i've
> deleted! if i download it
Peter Dembinski wrote:
> If you want to redirect me to Google, don't bother. IMO ninety percent
> of writings found on WWW is just a garbage.
Sturgeon's law: Ninety percent of everything is crap.
Andrew
[EMAIL PROTECTED]
--
http
Scott David Daniels wrote:
> Again polynomial, not exponential time. Note that there is no
> polynomial time algorithm with (k < 1), since it takes O(n) time
> to read the problem.
Being a stickler (I develop software after all :) quantum computers
can do better than that. For example, Grover's
Florian Lindner wrote:
> is there a function to escape spaces and other characters in string for
> using them as a argument to unix command? In this case rsync
> (http://samba.anu.edu.au/rsync/FAQ.html#10)
It's best that you use the subprocess module and completely skip
dealing with shell escapes.
kyo guan wrote:
> Can someone explain why the id() return the same value, and why
> these values are changing? Thanks you.
a=A()
id(a.f)
> 11365872
id(a.g)
> 11365872
The Python functions f and g, inside of a class A, are
unbound methods. When accessed through an instan
Stefan Nobis wrote:
> The other point is a missing (optional) statement to end blocks
> (so you optional don't have to mark block via whitespace). IMHO
> this comes very handy in some cases (like mixing Python and HTML
> like in PSP). From my experience i also would say beginners have
> quite some
Peter Dembinski wrote:
> So, the interpreter creates new 'point in address space' every time
> there is object-dot-method invocation in program?
Yes. That's why some code hand-optimizes inner loops by hoisting
the bound objection creation, as
data = []
data_append = data.append
for x in some_oth
Stefan Nobis wrote:
> From time to time I teach some programming (in an institution
> called "Volkshochschule" here in Germany -- inexpensive courses
> for adults). My Python course is for absolute beginners with no
> previous programming experience of any kind.
I also taught a beginning programmi
Matthew Thorley wrote:
> Does any one know if there a way to force the ElementTree module to
> print out name spaces 'correctly' rather than as ns0, ns1 etc? Or is
> there at least away to force it to include the correct name spaces in
> the output of tostring?
See http://online.effbot.org/2004_08
1 - 100 of 158 matches
Mail list logo