g one of the
built-in validators.
(which Asrarahmed would need to do, since he wants to restrict the
range of numbers available)
Also, this will not work quite right; you need something like:
def numeric(val):
try:
float(val)
except ValueError:
if val == '':
;test3']
output = '\\'.join(config[k] for k in keysToDump)
(note that, if you are using python2.3 or earlier, you will need to
write that last line as:
output = '\\'.join([config[k] for k in keysToDump])
)
HTH!
--
John.
___
But this is what strip is for.
>>> lst = ['0001.ext', '0230.ext', '0041.ext', '0050.ext']
>>> [s.lstrip('0') for s in lst]
['1.ext', '230.ext', '41.ext', '50.ext']
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ind will be in a different style, and many of the
experienced coders are used to an older style of wx coding.
But wxPython is better than Tkinter for apps you're going to spend
time on, or show to other people.
--
John.
___
Tutor maillist - Tu
ed some black magic.. but you should
generally avoid that)
However, the other question you should ask yourself is: should you be
using a dictionary instead? Rather than storing your data as
variables, you could store it in a dictionary. Then you can
dynamically access data however you like..
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
n = MySQLdb.connect (host = "localhost", user
> = "testuser", passwd = "testpass", db = "test")'
> "
Your indentation is wrong. Try outdenting all your code so it all
starts in the same column, and see if that helps.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
uot;)
> cursor = conn.cursor ()
> cursor.execute ("SELECT VERSION()")
> row = cursor.fetchone ()
> print "server version:", row[0]
> cursor.close ()
> conn.close ()
>
> but the problem remains :-(
This will fail because you have quote marks arou
ums[i] = sums[i] + eval(cols[i])
> return sums
>
> if __name__ == '__main__':
> import sys
> print summer(sys.argv[1])
>
> Unfortunately, the output is:
> [4, 20, 40, 16, 4.0]
Compare the output with the input. Where do you think the out
to next line
's' -- move to next line, or step into function call
'c' -- continue running until next breakpoint
'p' -- print; used to inspect variables, etc.
)
Note that pdb has difficulties with multithreaded programs.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
rguments.
Many people recommend not doing "from .. import *" if you can possibly
avoid it because of this precise problem!
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
name you give it is just a pointer
to that one 10. Remember, python is fully OO -- _everything_ is a
reference :-)
(this is also why there is no ++ operator)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
main window")
lab1.pack()
otherWindow = Toplevel()
otherWindow.title("Other window")
lab2 = Label(otherWindow, text="This is the other window")
lab2.pack()
root.mainloop()
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
rror: invalid syntax
What version of python are you running?
If you are running 2.3.x or earlier, you will need to rewrite this as:
numCols = max([len(cols) for cols in line_list])
(because you are using a generator expression, and they were only
introduced in 2.4)
--
John.
l the data is in a single cell!
> > it's a one cell list! Say what?
Have you tried looking at pagename in a text editor? If readlines()
is returning only one line, then you should be able to spot that in
the file.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
alse
True
>>> ['zero', 'one'][True]
'one'
It's more compact, but less clear (IMO), so I'm not a big fan.
Hmm, and it may not be faster either:
Morpork:~ repton$ python -m timeit -s 'n=13' 'x=["", "-"][n<0]
you could write this as
"files.extend(get_clist(clist))", which would be slightly more
efficient.
> My first attempt was to try
> [get_clist(c) for c in get_clists()]
>
> but this returns a list of lists rather than the flat list from the
> original.
This will do it:
>>> [x for k in clists for x in clists[k]]
['a', 'b', 'c', 'x', 'y', 'z', 'p', 'q']
Or [x for k in get_clists() for x in get_clist(k)] using your original
structure.
HTH!
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
, interestingly, my claim that using .extend is more efficient
appears to be false, at least for this example:
Morpork:~ repton$ python -m timeit -s
'lsts=[["a","b","c"],["1","2","3"],["x","y","z"]]' 'flattened = []'
'for lst in lsts:' ' flattened = flattened + lst'
10 loops, best of 3: 2.56 usec per loop
(not that there's much in it)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
'foo'
...
foo
So ... hmm. Not sure what's going on here.
I also notice that, according to
http://docs.python.org/ref/summary.html, '==' has higher precedence
than 'in'. Which means that
'foo == bar in baz' should group as '(foo == bar) in baz'. But Luke's
example contradicts this:
>>> lst = [1,2,3,4]
>>> 555 == 555 in lst
False
>>> (555 == 555) in lst
True
>>> 1 == 1 in lst
True
(this works because 1 == True)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
line, insert into database
3. Run query 'select blah from foo order by whatever limit 5'.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
dec -= next
return roman
Now, if we suddenly remember that the romans used 'Q' to represent
250, we can just edit our dictionary, and the rest of the code will
remain the same.
[note that this code will not produce strings like 'IV' for 4. OTOH,
as I recall, the Romans didn't do that consistently either..]
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e 'Q' for 250.
> Maybe you can change the dictionary for this one too.
Ahh, good point. I was thinking in terms of extra logic to figure out
the subtraction rules, but you could just use extra symbols :-)
--
John.
___
Tutor maillist - Tu
t;string slicing". The
tutorial covers this; look about half-way down the page:
http://docs.python.org/tut/node5.html
HTH!
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ke object open for writing.
To continue your example, you can do this:
f = open('test.conf', 'w')
conf.write(f)
f.close()
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ow
what you're doing, you can write your own python modules in C and
incorporate them into your python programs.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
uot; or "pairs". You can then invert that:
for f in fruit:
if not (f == "apples" or f == "pairs"):
print f, "is not an apple or pair."
You could then use DeMorgan's law to convert this to:
for f in fruit:
if f != "apples" and f != &qu
(i.e. the code where the NameError occurs)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
/group/nycpython/
Hope to see you there!
-John
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ed normally
(i.e. with the installer).
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Be aware that by default the Apache web server _WILL_ use the shebang line
even when running on Windows to try to find the Python interpreter when
python is run as a CGI script.
There is a setting in the configuration file that controls whether to use
the shebang line or to reference the window
Bob Gailer wrote:
>Andreas Pfrengle wrote:
>> Hello,
>>
>> I want to change the value of a variable whose name I don't know, but
>> this name is stored as a string in another variable, like:
>>
>> x = 1
>> var = 'x'
>>
>> Now I want to change the value of x, but address it via var.
>
>exec is the
x27;k': 42, 'z': 13}
And, obviously, you can combine both of these.
You might commonly see this when dealing with inheritance -- a
subclass will define some of its own parameters, and use *args/**kw to
collect any other arguments and pass them on to the base class. eg:
class MySubClass(BaseClass):
def __init__(self, x, y, foo='foo', *args, **kw):
BaseClass.__init__(*args, **kw)
# Do stuff with x, y, foo
> and I have not really found a clear or concise explanation via Google.
I don't think this counts as "concise", but I hope it is clear :-)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
and
last names to give to building security to make sure you can gain access to
the building. RSVP to [EMAIL PROTECTED] to add your name to the list.
More information can be found on the yahoo group page:
http://tech.groups.yahoo.com/group/nycpython
Hope to see you there!
-John
_
Kent and Alan: better?
.j
import zipfile
import os
import pylab as P
iFile = raw_input("Which file to process?")
def openarchive(filename):
""" open the cmet archive and read contents of file into memory """
z = zipfile.ZipFile(filename, "r")
for filename in z.namelist():
print f
gt;> hypotenuse = math.sqrt(hyp_squared)
Finally, "int" is a built-in type, so it's bad programming style to
use it as a variable name. (the same goes for "list", "str", and a few
others) That's why, in my example, I used "hyp_squared" as the name
for the hypotenuse squared.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
hon -m timeit -s
"import math" -s "x = 2" "y = math.sqrt(x)"' means "import math, set x
to 2, then run y=math.sqrt(x) many many times to estimate its
performance". From the interpreter, type 'import timeit;
help(timeit)' for more information)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e base class arguments when you create instances.
Whether you call BaseClass.__init__ early or late in the subclass init
method could depend on what your classes are doing. Remember, in
Python, __init__ only initializes objects, it doesn't create them.
It's just another
..
See this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286185
It has some suggestions and discussion that you might find helpful.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
re complex. I think there are recipes or examples
around on the net that you can probably find.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I have been searching for a while but I can't seem to find anything that
will do this, so...
In my python program I am starting a process using subprocess.Popen. This is
working fine, but the process I am starting starts several other processes.
Is there any way (using subprocess or a different mo
I am trying to make a simple animation, and this is what I have.
from livewires import games, color
games.init(screen_width = 1000, screen_height = 1000, fps = 50)
class Animation(games.Sprite):
files1 = ["stick1.jpg"]
files2 = ["stick2.jpg"]
def __init__(self):
self.animate1()
l explain that rstrip will strip off any charcters in the
argument from the right of the string you call it on.
So '10.0'.rstrip('.0') will remove any '.' or '0' from the right, leaving '1'.
'10.0'.rstrip('0') will remove
moved to
methods of strings. (e.g. string.capitalize(s) --> s.capitalize())
But that doesn't work for a couple of functions, like maketrans, so
those functions are not deprecated.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail
On 16/04/2008, Marc Tompkins <[EMAIL PROTECTED]> wrote:
> Does anyone out have experience with:
> - manipulating RTF files?
Is this any help to you: http://pyrtf.sourceforge.net/
?
--
John.
___
Tutor maillist - Tutor@pyt
7;: {220 : 2}, '5': {'220: 2}, '5': {238 : 1}, '6': {'238' :
> 2}, '7': {'220' : 1}}
[...]
> I am looking for a satrting point or any suggestions.
Can you write a function that will take a list and return a dictionary
with the counts of elements in the list?
i.e. something like:
>>> def countValues(valueList):
... # your code goes here
...
>>> countValues(['220', '238', '238', '238', '238'])
{'238': 4, '220': 1}
P.S. Your sample output is not a valid dictionary...
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ing with complex numbers, you might be
better off looking at scipy or some other module that provides more
mathematical grunt.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 21/04/2008, John Fouhy <[EMAIL PROTECTED]> wrote:
> >>> -1 ** (1.0/2.0)
> -1.0
Replying to myself:
It turns out that all is not what it seems. Let's try again:
>>> (-1)**0.5
Traceback (most recent call last):
File "", line 1, in
Valu
to benchmark dictionary access against Numpy arrays). If your program
design is good, the change should be too hard.
http://en.wikipedia.org/wiki/Optimization_(computer_science)#When_to_optimize
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
>>> x
8
Basically, python interprets integer literals starting with 0 as octal
numbers. It's an old convention from C (or earlier?). It doesn't
affect strings, so int('010') == 10 (unless you use eval).
HTH!
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
top in
any order). Then you can randomly generate a colour by generating a
random int in (0,1) and comparing with the proportions in the node.
Then you just have to update the weights for the colour you choose and
all nodes above it.
Should be log_2(n) to pick one colour and n.log_2(n) to pick colo
it. Note
that this means you won't check the second line --- you can maybe
visualise this with a simpler example:
>>> a = []
>>> nums = iter(range(10))
>>> for i in nums:
... a.append((i, nums.next()))
...
>>> a
[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]
On 29/05/2008, Robert William Hanks <[EMAIL PROTECTED]> wrote:
>
> Need ti find out whem a number o this form i**3+j**3+1 is acube.
> tryed a simple brute force code but, why this not work?
[deleted code]
Why doesn't this work? What problems are y
users group wiki page:
http://www.nycpython.org
Hope to see you there!
-John Clark
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
t work, even with
> QuickEdit..
Single right-click to paste.
User interface consistency would be a wonderful thing :-)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
out. system() may work if the preference is
> already set but startfile is specifically intended for that scnario.
>
> Alan G
>
> ___
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
--
-John Chandler
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
way to do this in Python?
Presumably you could do os.system('gksudo cp
/home/user/Desktop/menu.lst /boot/grub') ?
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
st):
return lst[i]
If you have an old version of python, this may not work. As an
alternative, try googling for "decorate-sort-undecorate".
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
eadlines()
and
file_object.readline()
I think I understand the differences, but can someone tell me if there's any
difference between what I define and the readlines() method?
-john
--
View this message in context:
http://www.nabble.com/readlines%2C-read%2C-and-my-own-get_contents%28%2
Hello, I would like to write a script that would have a command line option
of a pid# (known ahead of time). Then I want my script to wait to execute
until the pid is finished. How do I accomplish this?
I tried the following:
#!/usr/bin/env python
import os
import sys
def run_cmd(cmd):
"""RU
0 takes an additional 4 hours.
>
> Any ideas about what could be going on?
What happens if you reverse the loop?
i.e. change to:
for i in xrange(69, -1, -1):
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
a dict of the container_objects, so
when the object was created the name could be passed to the action() method, but
is there another way to do it?
Thanks in advance.
John
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
onstants.OLECMDID_PRINT,
> win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER)
>
>
> ___
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
-John Chandler
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
that includes effectively method signatures for the different COM
objects you can control. By inspecting this, you may be able to learn
what methods you can call on InternetExplorer.Application objects and
what arguments you need to give them.
--
John.
are in the bundle.
(e.g. something like "from PIL import GifImagePlugin" if you will be using GIFs)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ually clear gram.database because
> otherwise it keeps the data from previous calls to that function.
I think the OP is asking why this step is necessary.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
do you understand how assignment
with slices works?
e.g. can you predict the result of the following operations without trying it?
a = [1, 2, 3, 4]
a[1:3] = [7, 8]
print a
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
t there are no cases where obj==None and obj is None
will give different results (which is not true for == vs is in
general), so is there any practical difference? Maybe you save a
handful of cycles?
--
John.
___
Tutor maillist - Tutor@python.org
er than implicit, but worrying about what
happens to local variables when they go out of scope is a bridge too
far for most people.
(I don't want to criticise VB programmers because I am not one.
"Follow the local conventions" is generally always a good rule of
programming)
--
J
,%f)" % self.x, self.y" as "point_str = ("(%f,%f)" % self.x),
self.y". There are two "%f" expressions in the string, but you only
supplied one argument, self.x. Thus python tells you that there
aren't enough arguments. To deal with this, you need t
ypeError:
# do something else
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
tem__)
(by the way 2: if you follow the above code, and then display
f.fibsseq, you may see some nice curves caused by the " " between each
number. Aren't fibonacci numbers wonderful :-) )
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 03/07/2008, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "John Fouhy" <[EMAIL PROTECTED]> wrote
> > you can instead say:
> >
> > try:
> > foo()
> > except TypeError:
> > # do something else
> This makes slightly more sense,
mes you will execute your
loop, you should use a for loop instead:
for i in range(5):
# the stuff you want to do goes here
HTH!
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
> myList = [100, 'Test application']
>>> myList[0]
100
>>> myList[1]
'Test application'
I recommend reading a python tutorial if this is new to you.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
inedSlopeError" or "VerticalLineError" exception and raise that
instead of the ZeroDivisionError)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 09/07/2008, Kelie <[EMAIL PROTECTED]> wrote:
> I think comtypes or pywin32 do take care of some conversion between Python
> types and VB types. But they don't work with AutoCAD.
Hi Kelie,
This is a short excerpt from _Python Programming on Win32_:
"""In many cases, PythonCOM can translate be
On 09/07/2008, bob gailer <[EMAIL PROTECTED]> wrote:
> or just [ x for x in LIST if x ]
or filter(None, LIST). But that's a bit obscure.
(fractionally faster, though, according to my brief experiment with timeit)
--
John.
___
d, at the expense of
readability:
Morpork:~ repton$ python -m timeit -s 'dx, dy = (8, 5)' -s 'import
math' -s 'hyp = math.hypot' 'hyp(dx, dy)'
100 loops, best of 3: 0.501 usec per loop
)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
#x27;or_test' with 'old_expression'.
At any rate, here is one difference:
>>> a = range(5)
>>> b = range(5, 10)
>>> [x for x in a, b]
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
>>> (x for x in a, b)
File "", line 1
(x for x in a
On 10/07/2008, Kent Johnson <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 9, 2008 at 9:38 PM, John Fouhy <[EMAIL PROTECTED]> wrote:
> > Is the generator expression grammar right? How do I parse, e.g.,
> > '(x+1 for x in range(10))'? Seems like there's no
Check out the tutorial:
http://docs.python.org/tut/node8.html
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
, [('los angeles', []), ('san
francisco', [])]),
('texas', [('detroit', [])])]),
# etc
]
This lets you avoid messy isinstance testing to figure out if you've
got a value or a list of children.
(admittedly, it can be hard to keep track of the brackets, but good
indentation and a monospaced font should help out)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
powerful.
Look at
http://searchsecurity.techtarget.com/tip/0,289483,sid14_gci1303709,00.html
for example.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ooking at your other email, my guess is that you want to start
with SQL looking something like this:
select continent, country, state from world_globe
with the intention of getting back data that looks like:
[('America', 'United States', 'California'),
('America', 'United States, 'Texas'),
('America', 'United States, 'Washington'),
('America', 'Canada', 'Ontario'),
('Asia', 'Japan', None),
# etc
]
It would be fairly straightforward to take data looking something like
that and produce a tree.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
t to a dictionary like this:
world_dict = { 'north america':['united states', 'canada'],
'asia':['japan', 'china'], 'africa':['zimbabwe'] }
Your function should start like this:
def tupes_t
r own exception...
> def peek(self):
> length = len(self)
> if length == 0:
> return 0
The same applies here -- peeking at an empty stack should be an error
too. Otherwise, how can you tell the difference between an empty
stack and a stack where the top
Type "help", "copyright", "credits" or "license" for more information.
>>> def setXTo3():
... x = 3
...
>>> setXTo3()
>>> print x
Is that the result you expect? If not, can you explain it after
reading the web pages above? If it is w
;e:\\mm tests\\1. exp files\\5.MOC-1012.exp\n'
which, apart from the newline on the end, looks like exactly what you
want. If this isn't working for you, can you show what is going
wrong?
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 25/07/2008, Sam Last Name <[EMAIL PROTECTED]> wrote:
> Here wats i got so far. :) and also, is there a function for square root?
Have a look at the math module.
(you can also do fractional exponentiation.. remember, sqrt(x) is the
same as x**0.5)
teger (-b)
to a list ([..]). I recommend reading through the tutorial on
python.org.
PS. Please use the reply-all when using this mailing list so other
people can follow the conversation if they wish to.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
storing a third of the
Fibonacci numbers (the even ones), so we can cut that down to thirteen
gigabytes. Assuming my maths is correct and there's not too much
overhead in Python long integers :-)
(the solution, of course, is to avoid storing all those numbers in the
first place)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
another thought for you, once you've solved this problem: what
answer would you expect for the string 'aaa'?)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
x27;.join('abc')
'aabcbabcc'
Let's change the call slightly to make things more clear:
>>> 'abc'.join('ABC')
'AabcBabcC'
Does that make the pattern more clear?
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
x27;ABC'), you get:
'ABC'[0] + 'abc' + 'ABC'[1] + 'abc' + 'ABC'[2]
which is:
'A' + 'abc' + 'B' + 'abc' + 'C'
Hope this helps.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
, it might be easier to just do: '\n'.join(','.join(row)
for row in data)
I guess it depends what kind of programming you're doing, but in my
experience, .join() is definitely a useful function.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ch may alert you to broken data, or which you can
catch and deal with.
3. If a variable has a bad value (like a string where it should have a
float), the code will raise a ValueError, which again will alert you
to a problem.
(note that str() works on everything, and int() works on floats and
vice versa, s
t -- had
to take a copy of the database and inspect this. It seems that
firefox keeps a transaction open which has the effect of locking the
whole database (SQLite supports concurrent access, but it can only
lock the entire database). I guess that's fair enough -- from
Firefox's point of
ssible, or the best way to do it on different platforms.
~John
[1] http://www.agescibs.org/mauro/
[2] http://bluedynamics.com/articles/jens/python-ldap-as-egg-with-buildout
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
get
>
> gid = pwd.getpwnam(apache2_user)[pwd.pw_gid]
> AttributeError: 'module' object has no attribute 'pw_gid'
> [EMAIL PROTECTED]:~/kmotion2$ sudo ./install.py
>
> What am I missing ?
I haven't used the pwd module, but at
only one copy of each version installed, but I'm not sure which
versions would screw things up if they were to be removed.
Thanks for your help in understanding Python and proxy settings, and
how to fix settings if possible.
Thank you,
~John
[1] http://
ent
string representation from the default. If you want to change python
to display integers in hex instead of decimal by default, I can't help
you.. (well, maybe you could subclass int, and change __repr__ and
__str__ to return hex strings)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
801 - 900 of 1089 matches
Mail list logo