Exactly what do you want your mentor to do?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
e()
print("from MAIN")
print(room_final)
print()
print("a PRINT_MAP call from MAIN")
print_map()
print()
print()
===
partial sample output showing the current incorrect results:
a PRINT_MAP call from MAIN
+-+
|
it by hand. In fact, I think I will
process the loop entirely by hand, just the logic, and see how the
variables look that way.
Glad I could help.
PLEASE remember to always reply-all so a copy goes to the list.
Thanks,
Bill
On Mon, Aug 9, 2010 at 10:08 PM, bob gailer wrote:
On 8/9/20
textf]
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 8/17/2010 12:30 AM, Bill Allen wrote:
I am looking for some guidance about how to best utilize box drawing
characters(using unicode?) in as portable a way as possible in
Python. Any good guides out there for this?
Please tell us a bit more about your goals.
--
Bob Gailer
919-636-4239
arly of for-loops,
but not list comprehensions. The whole point is with a list comp,
you're forced to iterate over the entire sequence, even if you know
that you're done and would like to exit.
Take a look at itertools.takewhile!
result = [i%2 for i in itertools.takewhile(lamda x:i< 10, seq)]
self[0]
if len(self) == 2:
self.y = self[1]
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
def set(self, ix, value):
if len(self)>= ix + 1:
self[ix] = value
else:
raise AttributeError
def getx(self):
return self.get(0)
def setx(self, value):
self.set(0, value)
x = property(getx, setx)
def gety(self):
raise AttributeError
return g
def set(ix):
def s(self, value):
if len(self) >= ix + 1:
self[ix] = value
else:
raise AttributeError
return s
x = property(get(0), set(0))
y = property(get(1), set(1))
z = property(get(2), set(2))
--
Bob Gail
On 8/20/2010 8:35 PM, bob gailer wrote:
After yet more thought it gets even more better: I even added a unit test.
class PointND(list):
def __init__(self, *a_list):
super(PointND, self).__init__(a_list)
def getSet(ix):
def chklen(self):
if len(self) < ix + 1:
ra
very digit is placed on another line.
How can I prevent this ?
print int(digit2), # add a comma
Your algorithm is unnecessarily complicated.
You don't need to count first.
You don't need float.
getal=13789
while getal > 0:
getal, digit = divmod(getal, 10)
print digit,
But it is
e. I would think this would
be done with a while loop, but can't seem to get the details right.
Even though a while will work, you will have tied up the CPU until the
loop terminates. This is never a good idea.
What is your higher level goal?
--
Bob Gailer
919-636-4239
Chap
On 8/23/2010 1:09 PM, Gregory, Matthew wrote:
Bob Gailer wrote:
class PointND(list):
def __init__(self, *a_list):
super(PointND, self).__init__(a_list)
def getSet(ix):
def chklen(self):
if len(self)< ix + 1:
raise AttributeError
def get(s
tSet(1, 'y')
z = getSet(2, 'z')
p = PointND(1,2,3)
assert (p.x, p.y, p.z) == (1, 2, 3)
p.x = 6; p.y = 9; p.z = 5
assert (p.x, p.y, p.z) == (6, 9, 5)
try:
p = PointND(1,2)
p.z = 3
except AttributeError:
print 'Passed all tests'
--
Bob Gailer
919-636-4239
Ch
help.
How does this sound to you? Will you give it a try?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
7;S', then enter = Door to the South."
print "'E', then enter = Door to the East."
print "'W', then enter = Door to the West."
print "'Look at', then 'objects name'
massive crystal
chandelier. In front of you is round stone fountain, spewing water."""
return description
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
python is just too advanced
for me. I understand a lot of the teachings, but the examples seem
unwieldy and esoteric.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
1-emai...@domain.com"
To
"stuff more stuff still more stuff
word2-emai...@domain.com stuff after WORD2 "
The following did not work
newl = re.sub (r'WORD1-.*',"",line)
Please remember to explain "did not work".
Did you get an exception?
Did you get
print "The coin landed on tails " + str(tosses - heads) + " times \n"
print "The coin landed on heads " + str(heads) + " times \n"
Or even simpler:
import random
tosses = 100
heads = sum(random.randint(0,1) for i in range(tosses))
print ...
--
Bob Gai
int sys.argv
$hg commit "This is a commit name"
['C:\\hg.py', 'commit', 'This is a commit name']
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 9/8/2010 1:12 PM, Roelof Wobben wrote:
If I understand it right
You don't.
What does "put two strings into 1 string" mean. Provide an example.
What does the documentation say about join? What part of that do you not
understand?
--
Bob Gailer
919-636-4239
x , "is not a positive integer.Try again."
return -1
return x
y = readposint()
print y
while y == -1:
readposint()
print "You have entered : ", y
>
> Roelof
Francesco
Thank you.
I never thought that you can use a float and a integer to look if the numbe
On 9/11/2010 6:56 AM, Peter Otten wrote:
Steven D'Aprano wrote:
On Sat, 11 Sep 2010 09:56:41 am bob gailer wrote:
I never thought that you can use a float and a integer to look if
the number is a integer.
You can't.
I made that comment in the context of the OPs function:
def
1 Sep 2010 09:56:41 am bob gailer wrote:
I never thought that you can use a float and a integer to look if
the number is a integer.
You can't.
I made that comment in the context of the OPs function:
def readposint():
x = raw_input("Please enter a positive integer :")
try:
if (
getting a different result.
Here is where using the debugger and going step by step can help. I have
no experience with the IDLE debugger. Perhaps others can offer advice on
that.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Forwarding to the list.
Date: Mon, 13 Sep 2010 11:07:19 -0400
From: bgai...@gmail.com
To: tutor@python.org
Subject: Re: [Tutor] wierd replace problem
On 9/13/2010 8:19 AM, Roelof Wobben wrote:
Hello,
I h
On 9/13/2010 12:58 PM, Roelof Wobben wrote:
The orginal text can be found here :
http://openbookproject.net/thinkcs/python/english2e/resources/ch10/alice_in_wonderland.txt
There are no \ in that text!
--
Bob Gailer
919-636-4239
Chapel Hill NC
ters ...
Split into words (not letters?) where word is defined as
Count the frequency of each word.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/m
her it is
the beginning of a word, the end of a word, within a word, or outside
any word.
Take the beginning of the alice file, and BY HAND decide which category
the first character is in. Then the 2nd. etc. That gives you the
algorithm, Then translate
happend to the 0. 1 line
It works for me (after adding : at the end of the for statements, and a
parenthesis at the end of the print call).
>>> l = []
>>> for i in range(0,10)
...l.append(i+1)
...
>>> for i in range(0,10)
...print('%s. %s' % (i, l[i])
erence /6.8 Mapping Type - dict /it tells you the
answers to 1 and 5.
In the Python Reference /6.6.4. Mutable Sequence Types/ it tells you the
answer to 3.
In the Python Reference /5.9 Comparisons/ it tells you the answer to 4.
Regarding 3 there are several ways to loop through a sequence. Tuto
= 0
if match == 3:
amount = 3
[snip]
How about:
def change(amount, amts={1:0, 2:0, 3:3}):
return amts[match]
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription
:
Python v2.6.4 documentation - The Python Standard Library - 6.8 Mapping
Type - dict
you will see d[key] - compare that to what you wrote in version 2.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or
lso note the warning "Using iteritems() while adding or deleting
entries in the dictionary may raise a RuntimeError or fail to iterate
over all entries."
You should get a list rather than an iterator of all key-value pairs
then iterate over that list.
--
Bob Gailer
919-636-4239
C
Yet another way is to iterate thru the dict collecting a list of keys
of items to be deleted.
Then iterate thru that list deleting from the dict.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or
and p2 are preferred to P1 and P2.
Also why not initialize x and y thus:
p1 = Point(3,3)
That is what the __init__ is for.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription opt
= open(filename, mode='wb')
Did you mean "rb"? OP says files were written by another program.
will open the file. Do you have any documentation on the file structure?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist -
n self._address
@address.setter #use the property.setter decorator on this method
def address(self, addrvalue):
self._address = addrvalue
computer1 = Computer()
computer1.address = "test"
print computer1.address
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
On 9/21/2010 6:30 PM, Norman Khine wrote:
a = ['a', 'b', 'e']
>>> b = ['c', 'd']
i want to put the items of 'b' at [-2] for example.
>>> a[-2:-2]=b
>>> a
['a', 'c', 'd',
Sorry I hit the send button instead of the save button
On Thu, Sep 30, 2010 at 2:58 PM, Bob Gailer wrote:
> On Thu, Sep 30, 2010 at 2:38 PM, Roelof Wobben wrote:
>>
>> hello,
>>
>> Im following this page :
>> http://openbookproject.net/thinkcs/python/english2e/
sensitive?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
[snip]
I ran dis on a for loop and the equivalent comprehension.
I was surprised to see almost identical code.
I had assumed (and now wish for) that a comprehension would be a
primitive written in C and thus much faster!
--
Bob Gailer
919-636-4239
Chapel Hill NC
On 10/2/2010 8:02 PM, Steven D'Aprano wrote:
On Sun, 3 Oct 2010 01:17:39 am bob gailer wrote:
I ran dis on a for loop and the equivalent comprehension.
I was surprised to see almost identical code.
I had assumed (and now wish for) that a comprehension would be a
primitive written in
ging operation
from the
contents of a document.
As you can imagine, I'm pretty green in Python programming and I
was hoping
the learn by doing method would work. I need to get on with this
project,
though, and I'm kind of stuck. Any help you guys can give
7;test4', 'test5', 'test6', 'test7', 'test7uyuy', 'test8', 'test9',
'testgraph', ';s;juf;sfkh', 'zzrerhshhjrs']
My question is, why is everything except [:-2] in alphabetical order?
It doesn't really ma
ur homework and
post useful information. Else I will disappear from your life. But maybe
you will appreciate that?
(It took me less than a minute to spot the problem. You too can gain
that skill, but it will take work.)
--
Bob Gailer
919-636-4239
Chapel Hill NC
ursion. A loop is appropriate here.
while True:
try:
urllib2.urlopen('http://'+env.host_string+'\:8080')
except urllib2.URLError:
time.sleep(10)
else:
break
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor ma
on must be in quotes (due to the space in the
path). I don't know enough Perl to tell you how to do this.
In Python I would:
command = '"C:\Program Files\Python26\python.exe" include/weatherFeed.py
-c %s -s %s' % (city, state)
tions:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
When starting a new subject, please start with a new email. Do not
"hijack" an existing one, as that causes your query to appear as part of
the hijacked thread.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@pyt
Just for the heck of it:
heads = sum(random.randrange(2) for i in range(100))
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo
es and going at it that way, but since the challenge is listed
in a chapter dealing with Lists and Dictionaries (and tuples), I
figure there should be some way to solve it with those tools.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
s in
/home/david
Why do both the if and else get printed?
How do I do this without all the if statments?
I don't understand the if modtime > latest part, is this to loop over
the files and put the oldest last? I found that part in another
program and my program does not work without it.
David wrote:
I get this error with the int(time.localtime())
start_of_today = int(time.localtime())
TypeError: int() argument must be a string or a number, not
'time.struct_time'
Should have been start_of_today = int(time.time())
--
Bob Gailer
Chapel Hill NC
91
ong with that?
However:
>>> d[0].append(1)
>>> d
[[1]]
I guess I can't reference [0] on an empty list. (I come from a C
background.)
Can you have an empty array in C? If so, it does not have any elements,
so you can't refer to element 0.
--
Bob Gailer
Chapel Hill
cclpia...@comcast.net wrote:
Hello,
"but can't open with the application TextEdit"
What are you doing to open it? What does "can't open" mean"? Error
messages or what?
Could this be a resource fork issue? AFAIK Python does not reproduce the
resource fork.
-
. And because of that the strangeness occurred. I haven't
yet learned to work with the binaries as of yet.
Thanks!
Pat
4. Re: Copy file function works,but not with adding the date
copied (Alan Gauld) Tutor Digest Vol 60, Issue 69
On Feb 13, 2009, at 6:16 PM, bob gailer wrote:
/ HTTP/1.1" 200 13718
127.0.0.1 - - [13/Feb/2009:09:18:47 -0500] "GET
/theme/custom_corners/styles.php HTTP/1.1" 200 30709
I can create the label like this;
def label()
print "<%s\n>" % lfile
But I have no idea how to get it to work when a thread is updated.
thanks
-david
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
assigned.
It's time to take a look at the Language Reference.
6.3 Assignment statements.
assignment_stmt ::= (target_list "=")+ expression_list
a target list is not a tuple, even though it can look like one.
So I don't see it as any violation.
-
ervers.
Some other tutor may have a different answer. I propose you
open(filename, 'r') or open(filename, 'w').
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
topic was a
program to read 2 numbers, add them and print the sum. (In that era
programs were run in batch mode on a HP3000. The students edited the
program at their terminals, submitted them, waited a few minutes then
received listings from the printer down the hall. We did eventually
cover expre
if i define the function directly using the >>> prompt,
after that everything is fine
may you tell me where i have to save the file that defines the
function is order to use it later ?
is it a problem of path ?
Let's say you saved the file as foo.py. Then:
>>> import foo
>
George Wahid wrote:
I downloaded python 3.0.1 today and started experimenting with the new
print statement.
print is a function, not a statement.
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http
That would depend on the interface between your program and the
extensions. Do you have a design for this?
You might take a look at how to create a mozilla add-on for ideas on this.
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist -
sequence
No. It means that the object does not have a way to handle []. Many
objects are subscriptable besides sequences.
dict, set, objects with certain "special methods" e.g., __getitem__
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
really figure out what is going wrong here.
I don't see anything going wrong. All I see is some Python code.
Would you be kind enough to tell us why you think something is going wrong.
If there is an error post the traceback
If you get a result you did not expect tell us what the input
understand binsum = binsum * int(item) * 2 + binsum +
int(binum[i])
That does not agree with your verbal algorithm.
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
7;Association of Airline Cons.'), Cls('AALA',
'Adv. Activity Licence. Auth.'), ...]
That I think would be far more useful in the long run.
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
A hollow voice says PLUGH.
Be sure your lantern is lit!
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
preciated (and hopefully yahoo won't butcher my indentation).
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
roberto wrote:
On Sun, Feb 22, 2009 at 11:10 PM, bob gailer wrote:
roberto wrote:
hello
i have a question which i didn't solved yet:
i can define a function using the text editor provided by IDLE 3.0;
then i'd like to call this function from the python prompt
but when i tr
that is not the case please
tell us more about your goals and objectives.
I don't understand "act as routers".
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
bijoy franco wrote:
>
> Hi,
>
> Python throws OperationalError while trying to do any database
operations. I am using pgdb module.
>
> Code:
>
> import pgdb
>
> __metaclass__=type
>
> class addbook:
>
>
conn=pgdb.connect(dsn='localhost:secondbooks',user='postgres',password='postgres1')
ot;/usr/lib/python2.5/site-packages/pgdb.py", line 174, in execute
self.executemany(operation, (params,))
File "/usr/lib/python2.5/site-packages/pgdb.py", line 197, in executemany
raise OperationalError, "internal error in '%s': %s" % (sql,err)
pg.Operationa
t;The coded message is:", codedMessage
main()
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tut
def mode(data):
numdict = defaultdict(int)
for i in data:
numdict[data[i]] += 1
numlist = [(count, num) for num, count in nums.items()]
numlist.sort()
print 'The mode is: ', numlist[-1][1]
--
Bob Gailer
Chapel Hill NC
91
bob gailer wrote:
j mercedes wrote:
Hi, I have problem here...I am writing a program but I am getting
stucked at how to solve the mode of a series of numbers...any ideas???
The customary approach is to collect counts of each value in a
dictionary. Untested code follows:
from collections
Benjamin Serrato wrote:
> Please tell me why this code fails. I am new and I don't understand
why my formatting of my zip arguments is incorrect. Since I am unsure
how to communicate best so I will show the code, the error message, and
what I believe is happening.
>
> #!c:\python30
> # Filenam
Please use plain text rather than formatted text.
Small font size is hard for me to read.
So is large!
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
fanity" has therefore come to
describe a word, _expression_, gesture, or other social behavior which is socially constructed or interpreted as
insulting,
rude
and vulgar
or desecrating or showing disrespect.[1]
In many cultures it is less profane for an adult to curse
than it is for a ch
M:
Re: [Tutor] Formatting zip module arguments correctly
metolone+gm...@gmail.com
In hopes that you can see graphics, here is an extract:
[snip]
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/ma
Todd Zullinger wrote:
bob gailer wrote:
Please use plain text rather than formatted text.
Was sending this request in an html formatted message intentional? I
don't know about most folks, but I consider plain text to mean a
content-type of text/plain rather than text
_______
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
in retrospect.
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
but I do not understand the final paragraph.
It might help a little if you were to use more punctuation.
Are you asking a question?
Could you give an example?
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
appends the first one to
the next entry...and does this till it finds everything.
http://dpaste.com/33982/
Any Help?
dedent the 2nd for loop.
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
l\Shipping Totals\Shipping Totals -
2008\Shipping Totals 2008 East.xls'
thisDay = time.gmtime()[:3]
prevyear = datetime.datetime.today() - datetime.timedelta(days=365)
aYearAgo = prevyear.timetuple()[:3]
book = xlrd.open_workbook(thisyearFile)
dayexcel = xlrd.xldate.xldate_from_date_tuple(t
Please use reply-all so a copy goes to the list.
Eduardo Vieira wrote:
On Wed, Apr 22, 2009 at 9:47 AM, bob gailer wrote:
Eduardo Vieira wrote:
Hello! I’m not a programmer
Do you mean that you were not a programmer and are now becoming one?
In a way yes, I am aspiring
INDENTATION CORRECTION:
shipped = todaysList[shipindex]
total = sum([a for a in totals if type(a) == type(2.0)])
return shipped, total # specify the output(s) here
bob gailer wrote:
Please use reply-all so a copy goes to the list.
Eduardo Vieira wrote:
On Wed, Apr 22, 2009 at 9:47
han by exhaustion, I
cannot anticipate what will be found
What I am looking for is some help to get started, either with
explaining the implementation of one of the modules with respect to my
format, or with an approach that I could use from the base library.
What is your ultimate goal?
--
Bob Gailer
t understand urllib.urlopen(). Could some kind soul explain what I'm
doing wrong.
1) put a / after .com
2) encode it (in this case that means replace blanks with %20)
x=urllib.urlopen("http://maps.google.com/?q=18%20Tadlock%20Place%20Woodland%20CA";)
--
Bob Gailer
Chapel Hill NC
translate to Python fairly easily!
What do we do at steps 4ff if the line does not end in "yes" or "no"?
If you have not written any code make a stab at it. You could start by
asking "how in Python does one":
open a file
ending in 'yes'
line = data.read().strip()
if line:
if line.endswith('yes'):
state = 1
else state = 6
elif state == 1:
# code for state i
# more states
elif state == 6:
data.close()
break
To simplify things I'd create a function to read and s
() instead of invoking
this constructor directly. file is more suited to type testing (for
example, writing "isinstance(f, file)").
Unfortunately no explanation as to WHY open is preferred. I have long
wondered that myself.
Perhaps someone with more enlightenment can t
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ist.extend(numeric_list)
>>> string_list
['word', 3, 4, 6, 9]
In the relentless pursuit of terseness:
>>> class L(list):
... def add(self, end, *item):self[-end:-end] = item
>>> a=[4,6,'word',3,9]
>>> result=L()
>>> [result.add(
o this:
[4, 6, 'word', 3, 9]
should be:
['word', 3, 4, 6, 9]
Why not:
>>> sorted(lst, key=lambda x: (0, x) if isinstance(x, str) else (1, x))
['word', 3, 4, 6, 9]
Again in the relentless pursuit of terseness:
sorted(a, key=lambda x: (isinstance(x, int)
x27; is a relative path. It looks in the current directory.
Obviously that file is not in the current directory. So you must provide
the complete path.
That is no longer a Python issue!
The path to the desktop depends on OS and username!
I suggest you put the file in a different
101 - 200 of 1317 matches
Mail list logo