Re: Learning Modules, Arguments, Parameters (imma noob)

2015-09-24 Thread John Gordon
at variable as an argument to convert_kilo. The updated code would look like this: def main(): kilo = get_input() convert_kilo(kilo) def get_input(): kilo = float(input('Enter Kilometers: ')) return kilo def convert_kilo(kilo): miles = float(kilo * 0.6214) print( k

Re: Django (Python Web Framework) Tutorial

2015-09-26 Thread John Gordon
me directory. That should be fine. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: Question re class variable

2015-09-29 Thread John Gordon
is created, the ID of those two objects can be the same. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://ma

Re: Check if a given value is out of certain range

2015-09-30 Thread John Gordon
In alister writes: > I would stick with the OP's current solution > Readability Counts! I agree. 'if x < 0 or x > 10' is perfectly fine. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is fo

Re: Check if a given value is out of certain range

2015-10-01 Thread John Gordon
at, I don't believe that you cannot figure out how to Certainly we can understand it. But it takes ever-so-slightly more effort to do so. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: Check if a given value is out of certain range

2015-10-01 Thread John Gordon
ept of "not"? I wasn't commenting directly to the "ask not..." quote; I was referring upthread to the choice between not 0 <= x <= 10 and x < 0 or x > 10 Both are of course understandable, but in my opinion, the latter one takes slightly less effort to gro

Re: Check if a given value is out of certain range

2015-10-01 Thread John Gordon
;. In my opinion, when comparing a variable to a constant, it's more natural to have the variable on the left and the constant on the right, so that's one strike against this code. Another strike is that the code isn't consistent with itself; it puts the variable on the left in t

Re: Trouble running

2015-10-06 Thread John Gordon
u using to try to save? Is it a text editor? What happens when you try to save? How do you know it didn't work? Do you get an error message? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread John Gordon
ke all three of your if statements start out with this condition: if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 So you could reorganize your code by putting an if statement at the top that only checks this condition. Then, indented under

Re: How to handle exceptions properly in a pythonic way?

2015-11-02 Thread John Gordon
at can arise during execution of the > requests.get(url)? The best way is probably to do nothing at all, and let the caller handle any exceptions. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: new to python, help please !!

2015-11-11 Thread John Gordon
when i gets incremented, but it doesn't work like that. When you increment i, you also have to reassign s1 and s2. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: Why does 'as' not recognized?

2015-11-12 Thread John Gordon
' > >>> as=cats[2] > SyntaxError: invalid syntax > >>> as=cats > SyntaxError: invalid syntax > >>> as > SyntaxError: invalid syntax 'as' is a python language keyword, and cannot be used for variable names. -- John Gordon

Re: Is it useful for re.M in this example?

2015-11-12 Thread John Gordon
not contain newline characters. If it did, you would see the effect of re.M. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies"

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-17 Thread John Gordon
x27;t specifically need a sequence. Is the same true for the 'size' keyword argument of np.random.normal()? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Go

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-17 Thread John Gordon
e contents of the tuple were ever to change, it would be much easier to simply change it in once place (the definition of sz), rather than having to edit several different occurrences of (n_iter,) in your code. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.co

Re: What is a function parameter =[] for?

2015-11-18 Thread John Gordon
. > Could you explain a little to me? > Thanks, > def eList(val, list0=[]): > list0.append(val) > return list0 > list1 = eList(12) > list1 = eList('a') That is a default parameter. If eList() is called without an argument for list0, it will use [] as the defa

Re: anyone tell me why my program will not run?

2015-11-22 Thread John Gordon
u meant to have this piece of code indented under the while loop above? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: Not Responding When Dealing with Large Data

2014-06-18 Thread John Gordon
es'? Does it actually crash? -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: comtypes

2014-06-21 Thread John Gordon
You can use help() and dir() to display more information about an object. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: I am confused about ' and "

2014-07-10 Thread John Gordon
nd vice-versa. For example: string2 = "It's a beautiful day in the neighboorhood." string1 = 'He said to me, "Hello Thomas."' -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House&#x

Re: Subtracting two dates in python

2014-07-31 Thread John Gordon
ike this: now_date = datetime.now() Subtract the two datetime objects to obtain a timedelta object: mydelta = now_date - user_date Look at the days attribute to get the difference in days: mydelta.days -- John Gordon Imagine what it must be like for a real medical doctor to

Re: Python Classes

2014-08-04 Thread John Gordon
lass. All other classes inherit from Object. Within a class, self is a reference to the current class instance. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: Wikibooks example doesn't work

2014-08-06 Thread John Gordon
uld help tremendously if you gave us more detail than "it doesn't work". Do you get an error message? Does the program not execute at all? Does it execute, but give unexpected results? -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: Test for an empty directory that could be very large if it is not empty?

2014-08-07 Thread John Gordon
rectory entry itself. On the system I'm writing from, a freshly-created directory is 4K in size, and will grow in 4K chunks as more and more files are created within the directory. However, the directory entry does not shrink when files are removed. -- John Gordon Imagine what it m

Re: Newbie needing some help

2014-08-08 Thread John Gordon
rollback() Again, as others have said, using a bare 'except:' statement will catch and hide any possible error, leaving you mystified as to why nothing happened. > # disconnect from server > db.close() -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: Ground Up Python/Xpath lessons

2014-08-09 Thread John Gordon
amples, I'm confused -- don't you *want* very basic examples? > they don't really teach you assuming you know nothing. Try http://www.w3schools.com/xpath/xpath_intro.asp -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch &#

Re: how to get the subject of email?

2014-08-09 Thread John Gordon
similar to yours. Perhaps something in the code will help. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: why i can't copy mail with imaplib?

2014-08-10 Thread John Gordon
In luofeiyu writes: > self.con.select("inbox") > self.con.copy(b"1","[Gmail]/&kc2JgQ-]") > why i can not copy the first email into my important mailbox? What happens when you run the above code? Do you get an error? -- John Gordon Imag

Re: Need simple Python Script

2014-08-13 Thread John Gordon
y windows pc as input.Can anybody have > any solution? I use command prompt and gedit to learn python. What is the script supposed to *do* with the image file? -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or

Re: problem on top-post

2014-08-14 Thread John Gordon
In luofeiyu writes: > the best way is to excerpt only the relevent portions of the parent > message ,not top-post nor bottom-post , right? The followup text appears underneath the quoted parent message, thus bottom-post. -- John Gordon Imagine what it must be like for

Re: problem on top-post

2014-08-15 Thread John Gordon
In Ben Finney writes: > "Bottom-post" usually refers to the inferior practice of quoting a > message (entirely or large amounts) and then indiscriminately responding > to all of it below all of the quoted text. I was unaware of that meaning. -- John Gordon Imag

Re: Unicode in cgi-script with apache2

2014-08-15 Thread John Gordon
; 1791: ordinal not in range(128) The error traceback should display exactly where the error occurs within the script. Which line is it? -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is going to be hard

2014-09-03 Thread John Gordon
f range There are fewer than 13 items in steve, so when x reaches 13 this error pops up. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: My backwards logic

2014-09-05 Thread John Gordon
and print "This number is prime" if isprime is still True. 2. Create a separate function just for testing if a number is prime, which returns True or False. Then call that function within your while loop. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: hashlib suddenly broken

2014-09-18 Thread John Gordon
orts some other module which has a local module of the same name? SHA1 has been deprecated for some time. Maybe a recent OS update finally got rid of it altogether? -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House',

Re: hashlib suddenly broken

2014-09-18 Thread John Gordon
t; raise ValueError('unsupported hash type %s' % name) > ValueError: unsupported hash type sha1 Could there be two different versions of hashlib.py on your system? -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to write a html to automatically display the dictionary?

2014-09-23 Thread John Gordon
In luofeiyu writes: > x={'f1':1,'f2':2,'f3':3} > how can i create the following html file automatically with python to > display x ? You might want to use something other than a dictionary, as the order isn't guaranteed. -- John Gordon

Re: Flask and Python 3

2014-09-23 Thread John Gordon
everything correct,acessing http://localhost:8000 works, but > http://localhost:8000/blog/post/ gives me ' 500 Internal Server Error '. > Why? Have you looked in the http server error log for an explanatory error message? -- John Gordon Imagine what it must be like for a

Re: python on Linux

2014-10-09 Thread John Gordon
In Igor Korot writes: > sys.path.append('~/MyLib') > I.e., will '~' sign be expanded correctly? Not as written. Use os.path.expanduser() to get user's home directories. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@p

Re: How to select every other line from a text file?

2014-10-13 Thread John Gordon
27; statement to start the loop over and read another line. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list

Re: Building lists

2014-10-20 Thread John Gordon
# start with an empty list shopping_list = [] # make a 'cheese' item cheese = ('Cheese', { 'Walmart' : 5.00, 'Publix': 5.50, 'Costco': 4.99 } ) # add cheese to the shopping list shop

Re: Python: Deleting specific words from a file.

2011-09-08 Thread John Gordon
the modified string; it does not alter the existing string. Do this instead: line = line.replace(word, "") > fout.write(line) > fin.close() > fout.close() > I have put the code above in a file. When I execute it, I dont see the > result file. I am not sure what the error

Re: What is wrong with this code?

2011-09-15 Thread John Gordon
= '\end{document}' > #this is where you come in: type what you want below using the terms > explained in howto.pdf > print ('it's an article it's called test} here it is: Hello World! > it's over!') You cannot use words like it's insid

Re: Question on Manipulating List and on Python

2011-09-29 Thread John Gordon
n is posted by one of my colleagues, what makes > Python so fast? Fast compared to what? Why does your colleague believe it should be slower? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on Manipulating List and on Python

2011-09-29 Thread John Gordon
n C++ or Java. If it is, it's because the C++ or Java code is doing more work. Do you have a sample Python program and a sample C++ or Java program to demonstrate the speed difference? -- John Gordon A is for Amy, who fell down the stairs gor..

Re: HTTP Persistent connection

2011-10-03 Thread John Gordon
a dumb question, but if you want to reuse the same connection, why are you declaring two separate HTTPConnection objects? Wouldn't you want to reuse the same object? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bea

Re: Writing file out to another machine

2011-10-05 Thread John Gordon
s running, onto, say > S:/IT/tmp how can I specify/do this? Thanks, RVince scp file host:/some/location -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "

Re: Writing file out to another machine

2011-10-05 Thread John Gordon
to, say > > S:/IT/tmp how can I specify/do this? Thanks, RVince > open('S:/IT/tmp','w') ?? I assume he intended "S:" to indicate a remote server. -- John Gordon A is for Amy, who fell down the stairs gor.

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread John Gordon
In xDog Walker writes: > What is this io of which you speak? It was introduced in Python 2.6. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, &

Benefits of xml.dom.minidom?

2011-10-20 Thread John Gordon
? What is it doing with all that memory and CPU? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.o

Re: Importing a module from a non-cwd

2011-10-24 Thread John Gordon
file.py can import the my_module.py module ? If PYTHONPATH and/or sys.path contain /home/candide/foo/, then you should be able to: import my_module Or, if foo/ is a real module (i.e. it contains an __init__.py file), this should work: import foo.my_module -- John Gordon A is

Re: Data acquisition

2011-10-25 Thread John Gordon
cases? Does PYTHONPATH and/or sys.path have the same value in both cases? Show us an exact transscript of both executions. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward

Re: Data acquisition

2011-10-25 Thread John Gordon
ot;. Or do you mean something else? I do > not receive any errors, only different results ... I was more interested in the exact commands you used to run both cases, rather than the output. -- John Gordon A is for Amy, who fell down the stairs gor

Re: Dynamically creating properties?

2011-10-27 Thread John Gordon
tion', 'programmer') For methods, use an existing method name (without the trailing parentheses) as the attribute value, like so: myx.method = float # assigns the built-in method float() -- John Gordon A is for Amy, who fell down the stairs gor...@

Re: How filecmp walk into subdirectories?

2011-11-01 Thread John Gordon
subdirectories. If you want subdirectories, use report_full_closure(). -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" --

Re: Dictionary sorting

2011-11-03 Thread John Gordon
how. Is there a way to not sort > them and leave the order as is? Dictionaries don't maintain the order of the items. If you want to keep track of the order in which the items were inserted, you'll need to do that yourself using a separate mechanism (a list, for example.) -- John G

Re: match, concatenate based on filename

2011-11-03 Thread John Gordon
= "%s.mus.blast.fasta" % Q file3 = "%s.query.fasta" % Q target = "%s.concat.fasta" % Q concatenate(file1, file2, file3, target) Assuming that there are exactly three files to be concatenated for each value of i. -- John Gordon A is for Amy, who fell down the s

Re: Python ORMs Supporting POPOs and Substituting Layers in Django

2011-11-07 Thread John Gordon
to get as much feedback as I've used Django and it seems to be a very nice framework. However I've only done one project so I haven't delved too deeply. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is

Re: Extracting elements over multiple lists?

2011-11-07 Thread John Gordon
In JoeM writes: > a=[1,2,3,4,5] > b=["one", "two", "three", "four", "five"] > c=["cat", "dog", "parrot", "clam", "ferret"] > what is the most pythonic method of removing the firs

Re: Python ORMs Supporting POPOs and Substituting Layers in Django

2011-11-07 Thread John Gordon
In John Gordon writes: > In <415d875d-bc6d-4e69-bcf8-39754b450...@n18g2000vbv.googlegroups.com> Travis > Parks writes: > > Which web frameworks have people here used and which have they found > > to be: scalable, RAD compatible, performant, stable and/or providing &g

Re: Extracting elements over multiple lists?

2011-11-07 Thread John Gordon
oes a fair bit of unneccessary work (creating a list comprehension that is never used.) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlyc

Re: file extension while saving Python files

2011-11-08 Thread John Gordon
ist selection for specifying the file type? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: No matter what I do, IDLE will not work...

2011-11-10 Thread John Gordon
all, so I am wondering why you mentioned it.) By typing "python" on your desktop, are you running plain Python, or are you running IDLE? Did you install Python and IDLE on the desktop machine separately? Did both installations succeed? -- John Gordon A is for Amy,

Re: Get keys from a dicionary

2011-11-11 Thread John Gordon
s string. Are you stating this can be done, or are you asking if it can be done? Questions usually end with a question mark. (Are you a native English speaker?) > Whithout loop all dict. Just it! print "%s" % x -- John Gordon A is for Amy, who fell down the stairs

Re: Get keys from a dicionary

2011-11-11 Thread John Gordon
;]['bar'] ) > >>> result > Should print : > ... foo bar I don't think there's a simple way to do what you want. You could inspect the whole dictionary to find the keys that map to a given value, like so: def MyFunction(mydict, x): for k1 in mydict:

Re: Get keys from a dicionary

2011-11-11 Thread John Gordon
hout that, I don't think there's an answer for him. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app)

2011-11-14 Thread John Gordon
double-clicking on the .py file? What application is associated with .py files? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies&q

Re: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app)

2011-11-14 Thread John Gordon
s associated with .py files. (You mentioned running IDLE, but I don't see that it was given as the default application for opening .py files.) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app)

2011-11-14 Thread John Gordon
ing that the .py file association points to the correct application might be worthwhile. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycr

Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread John Gordon
7 is behind this. If so, it's good-bye Python. It was working originally, right? So the problem can't really just be Win 7. Can you add IDLE manually to the associated applications list? -- John Gordon A is for Amy, who fell down the stairs

Re: sqlalchemy beginner

2011-11-21 Thread John Gordon
_name', Unicode(255), default=u''), -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: What I do and do not know about installing Python on Win 7 withregard to IDLE.

2011-11-23 Thread John Gordon
In "Alemu Tadesse" writes: > scientific package is not working and complaining about not able to > find/load DLL ... frustrating for the first day in the python world. ANY > tip ? Post the exact error message you're getting. Also post your code, if it's n

Re: Python 2.7.2 on XP

2011-11-23 Thread John Gordon
In "Alemu Tadesse" writes: > I am new to python. I do not know why my python editor (for 2.7.2) > changes everything to just black and white after saving. No color for What editor are you using? There are quite a lot of them. -- John Gordon A is for Amy, w

Re: Python 2.7.2 on XP

2011-11-23 Thread John Gordon
In "Alemu Tadesse" writes: > I am saving it with .py extention It would really help us answer your question if you identified which editor you're using. IDLE? PyScripter? Eclipse? PyCharm? -- John Gordon A is for Amy, who fell down the stair

Re: lxml precaching DTD for document verification.

2011-11-27 Thread John Gordon
of effort by just using > the validator the W3C provides (http://validator.w3.org/). With regards to XML, he may mean that he wants to validate that the document conforms to a specific format, not just that it is generally valid XML. I don't think the w3 validator will do that. -- Joh

Re: Dynamic variable creation from string

2011-12-07 Thread John Gordon
D['a']+D['b']+D['c'] > Is there a way to create three variables dynamically inside Sum in > order to re write the function like this? Do you want to sum all the values in D? If so, that's easy: def Sum(D): my_sum = 0 for item in D: m

Re: test for list equality

2011-12-15 Thread John Gordon
In <61edc02c-4f86-45ef-82a1-61c701300...@t38g2000yqe.googlegroups.com> noydb writes: > My sort issue... as in this doesn't work > >>> if x.sort =3D=3D y.sort: > ... print 'equal' > ... else: > ... print 'not equal' > ... > not eq

re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
all zeroes. Thanks! -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
lon if longest_match: ip6 = re.sub(longest_match, ':', ip6, 1) Thanks! -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Ti

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
; > re.sub(pattern, r'\1', string, flags=re.IGNORECASE) Perfect. Thanks Ian! -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
EDC:BA98:7654:3210:FEDC:BA98:7654:321" > print IPv6(addr_string).to_short_form() This does sound like a more robust solution. I'll give it some thought. Thanks Roy! -- John Gordon A is for Amy, who fell down the stairs gor...@panix.c

Re: Unable to install xmldiff package on WIndows7

2012-01-05 Thread John Gordon
sions/maplookup.c Can you rename that directory to something that does not contain spaces and try it again? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gor

Re: Zealotry [was Re: how to install lxml in window xp?]

2012-01-13 Thread John Gordon
In <4f0fbad0$0$29984$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano writes: > Why is it that only Linux and Mac users are accused of being "zealots"? Perhaps because Windows, being in a position of market dominance, doesn't *need* zealots. -- John Gordon

Re: Parsing XML RSS feed byte stream for tag

2013-02-07 Thread John Gordon
uld be greatly appreciated. You haven't included the BeautifulSoup code which attempts to parse the XML, so it's impossible to say exactly what the error is. However, I have a guess: you said you're trying to return the first child. Based on the above output, the first child is t

Re: Web Testing Frameworks

2013-02-12 Thread John Gordon
In Greg Lindstrom writes: > I'm not wanting to start anything here, but I am wanting to automate > testing of my Django-based websites. A quick search on Google turns up a Have you looked at using the built-in django test client? -- John Gordon A is for Amy, wh

Re: New User-Need-Help

2013-02-15 Thread John Gordon
hould be broken into two separate lines: print "Game Over" raw_input("\n\nPress Enter Key to exit") I can't believe the book put all that code on one line... -- John Gordon A is for Amy, who fell down the stairs

Re: Howto parse a string using a char in python

2013-02-15 Thread John Gordon
just need the "123456" > substring.(left of the :) > I have looked at regular expressions and string functions, so far no luck. > Custom function required? Use the split() string function. -- John Gordon A is for Amy, who fell down the stai

Re: New User-Need-Help

2013-02-15 Thread John Gordon
y in version 3. Change your print statement to look like this: print("Game Over") -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashly

Re: improving performance of writing into a pipe

2013-02-20 Thread John Gordon
this. If you don't know what exception is being raised, temporarily remove the try/except statements and run the code directly. You'll get the exception, and then you'll know which one it is. -- John Gordon A is for Amy, who fell down the stairs gor...

Django error tracebacks

2013-02-27 Thread John Gordon
his? (I'm using Django 1.3 instead of the current 1.4 version, but still, this seems like a pretty basic thing to get wrong.) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread John Gordon
the file exists, you know that the program has already run today and you can read the file to obtain the previous serial number. If the file does not exist, you know the program has not yet run today and you can start the serial number at 1. -- John Gordon A is for Amy, wh

Re: An error when i switched from python v2.6.6 => v3.2.3

2013-03-07 Thread John Gordon
u have the close-parentheses in the wrong place. The line should be: os.system( 'python metrites.py > %s' % htmltemp ) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: working with dict : incrementing dict dynamically

2013-03-11 Thread John Gordon
ill always evaluate true, because you're comparing region_num to itself. > num_pixel = +1 This doesn't store the value of num_pixel in the dictionary. You probably want to do this instead: segments[region_num] += 1 -- John Gordon A is for Amy, who f

Re: Test a list

2013-03-20 Thread John Gordon
[]' is wrong. 4. The way you have this code set up, you would need two loops: an outer loop for i from 1 to 25, and an inner loop for the items in t. 5. As others have said, this is a poor way to go about it. You want to use "if i in t". -- John Gordon A is f

Re: how does the % work?

2013-03-22 Thread John Gordon
ree single-quotes, etc.) The error message also says that the print statement has a close-parenthesis after the string and before the arguments, which may be real problem. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: I need a neat way to print nothing or a number

2013-03-26 Thread John Gordon
In c...@isbd.net writes: > What's a neat way to print columns of numbers with blanks where a number > is zero or None? print number or ' ' -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basi

Re: os.system() with imbeded quotes on centos

2013-04-01 Thread John Gordon
r in shell commands. You'll need to quote or escape it. Try this: someip = '192.168.01.01' var1 = 'lynx -dump "http://' + someip + '/cgi-bin/.log&.submit=+++Go%21+++" > junk' Note the extra pair of double-quotes around the http

Re: Switching from Apche to LiteSpeed

2013-04-01 Thread John Gordon
> I see weird encoding although inside my python script i have: > #!/usr/bin/python > # -*- coding=utf-8 -* I believe the syntax is to use a colon, not an equal sign. i.e.: # -*- coding: utf-8 -*- Your example is also missing the final dash after the asterisk. -- John Gordon

Re: Help

2013-04-01 Thread John Gordon
he attached program doesn't (appear to) work with sums at all; why would you want to use it? Writing a new program from scratch would seem to be a better choice. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for B

Re: Help

2013-04-01 Thread John Gordon
rt of implies that you want to use the program exactly as it was posted, without modifications. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashly

<    1   2   3   4   5   6   7   >