Re: Append to python List

2013-05-09 Thread Gary Herron
On 05/08/2013 11:36 PM, RAHUL RAJ wrote: Checkout the following code: sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] output=[] output=[x for x in sample2 if x not in output] This statement is not doing what you expect. It is not building a list in the variable named outpu

Re: create new python file

2013-06-04 Thread Gary Herron
file. For instance: with open("Hello.py", "w") as f: print("print('Hello world')\n", file=f) will create a file containing a simple one-line Python program. If you meant something else, then please take the time to provide more detail. Gary

Re: Default Value

2013-06-19 Thread Gary Herron
the function (or rather with each call to the function that does not supply its own value for L). Gary Herron print(f(1)) print(f(2)) print(f(3)) This will print [1] [1, 2] [1, 2, 3] How the list is retained between successive calls? And why? -- Dr. Gary Herron Department of Computer Sc

Re: n00b question on spacing

2013-06-21 Thread Gary Herron
all in one statement.) fmt = "Item wrote to MongoDB database %s/%s" msg = fmt % (settings['MONGODB_DB'], settings['MONGODB_COLLECTION']) log.msg(msg, level=log.DEBUG, spider=spider) Gary Herron -- Dr. Gary Herron Department of Computer Scien

Re: analyzing time

2013-07-05 Thread Gary Herron
somewhere that discusses statistics and analysis. Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list

Re: RAM slots problem

2013-07-09 Thread Gary Herron
On 07/08/2013 10:06 PM, saadharana wrote: I've got some annoying problem with RAM. I was depth cleaning my case, everything regular, it wasn't my first time. And when I put it all together and powered it on, it wasn't working, just beeps fast. But how that happend when I put all back in like it w

Re: Storing a very large number

2013-07-17 Thread Gary Herron
dex the 209th character: >>> str(12**345) '2077446682327378559843444695582704973572786912705232236931705903179519704325276892191015329301807037794598378537132233994613616420526484930777273718077112370160566492728059713895917217042738578562985773221381211423961068296308572143393854703167926779929682604844469621152130457090778409728703018428147734622401526422774317612081074841839507864189781700150115308454681772032' >>> str(12**345)[209

Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Gary Herron
hed parentheses. ... n = n2 / m ... r = n2 - n * m ... rtn.append(m * x[n] + r * (x[n + 1] - x[n])) ... print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn ... rtn However, I am getting the error "expected an indented block"

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Gary Herron
On 07/29/2013 01:56 PM, Devyn Collier Johnson wrote: I tried Pyglet in a Python3 and a Python2 script, but both fail. The error code is below and the script is attached. The 'boot.ogg' file is Ubuntu's default bootup sound. I got my code from this link (http://guzalexander.com/2012/08/17/playin

Re: binary key in dictionary

2013-07-30 Thread Gary Herron
tes a key-value pair in the dictionary, but the line d[2] += 98 tries to add 98 to an already existing value at d[2], But there is no value at d[2] until you set it: d[2] = 0 # for instance You may want to look at defaultdict from the collections module. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: What’s the differences between these two pieces of code ?

2012-07-06 Thread Gary Herron
gh 12. What are we supposed to be comparing? Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list

Re: python CAD libraries?

2012-09-10 Thread Gary Herron
recommend some good ones for me? Thanks a lot!! Try PythonCAD: http://sourceforge.net/projects/pythoncad/ (Google would have been faster. :-) ) Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo

Re: how to insert random error in a programming

2012-10-15 Thread Gary Herron
On 10/15/2012 06:55 AM, Debashish Saha wrote: how to insert random error in a programming? Drink several beers before you start programming. :-) -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo

Re: date and time comparison how to

2012-10-29 Thread Gary Herron
dt = datetime.datetime.fromtimestamp(mtime) -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list

Re: Conversion of List of Tuples

2012-12-04 Thread Gary Herron
On 12/03/2012 11:58 AM, subhabangal...@gmail.com wrote: [(1,2), (3,4)] >>> L=[(1,2), (3,4)] >>> >>> [b for a in L for b in a] [1, 2, 3, 4] -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.

Re: Python, email temperature

2012-12-22 Thread Gary Herron
Could it be this easy? In one spot you refer to it as "cpu_temperature" and in another as "cputemp". If that's not it, you'd probably better show us your *real* code, otherwise we're just guessing. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, email temperature

2012-12-22 Thread Gary Herron
On 12/22/2012 12:54 PM, KarlE wrote: On Saturday, December 22, 2012 9:44:39 PM UTC+1, Joel Goldstick wrote: On Sat, Dec 22, 2012 at 3:36 PM, Alexander Ranstam wrote: Hi! Im totally new to Python, and im using it on my Raspberry pi. I found a program that sends an email, and one that checks

Re: how to solve complex equation?

2013-01-01 Thread Gary Herron
of study. No one is going to put that kind of time into answering your question here. -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list

Re: Using an object inside a class

2012-01-23 Thread Gary Herron
that being the builtins. -- Gary Herron, PhD. Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting 1172026 entries

2012-05-06 Thread Gary Herron
or deletion and garbage collection. Instead do the in-place sort: temp.sort() Same result, less thrashing. This will make your program slightly more efficient, HOWEVER, it is not the solution of your week-long sort problem. Gary Herron On Sun, May 6, 2012 at 6:26 PM, J. Mwebaze <

Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-16 Thread Gary Herron
math # to get your stuff but named math. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Can someone help please

2011-07-21 Thread Gary Herron
with your expectations. If I've misunderstood your question, the please reword and resend it, but this time include more information: The files in '.', their content, the output you do get, and the output you expected. Gary Herron -- Gary Herron, PhD. Department of Compute

Re: Can someone help please

2011-07-21 Thread Gary Herron
dlines() f.close() message = """\ Subject: %s %s """% (SUBJECT,total) I also changed read to readlines(). That won't work (You must not have even tried to run this.) The call f.readlines() returns a list which causes an error when added to a strin

Re: how to separate a list into two lists?

2011-08-06 Thread Gary Herron
, any methods to make this done? List comprehension: L1 = [item[0] for item in L] L2 = [item[1] for item in L] which *is* still a loop. (You are going to have to write *really* arcane code to have no loop.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: pairwise combination of two lists

2011-08-17 Thread Gary Herron
nt function to do this, especially when li1 and li2 are long lists. I found zip() but it only gives [('a', '1'), ('b', '2')], not exactly what I am looking for. Thank you. - Yingjie >>> li1 = ['a', 'b'] >>> li2 = ['1', '2'] >>> print [a+b for a in li1 for b in li2] ['a1', 'a2', 'b1', 'b2'] Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Floating point multiplication in python

2011-09-06 Thread Gary Herron
On 09/05/2011 10:57 PM, xyz wrote: hi all: As we know , 1.1 * 1.1 is 1.21 . But in python ,I got following : 1.1 * 1.1 1.2102 why python get wrong result? Who can tell me where's the 0.0002 from? It's not a python errorIt's the nature of floating point arithm

Re: I am confused by

2011-09-07 Thread Gary Herron
re is a "deepcopy" in the library which may do what you expect. Gary Herron -- Gary Herron, PhD. Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2011-04-01 Thread Gary Herron
On 04/01/2011 12:52 PM, Karl wrote: Hello, one beginner question: aList = [0, 1, 2, 3, 4] bList = [2*i for i in aList] sum = 0 for j in bList: sum = sum + bList[j] Your j is already an element of bList. You don't need to index bList again. Instead do for b in bList:

Re: Fibonacci series recursion error

2011-04-29 Thread Gary Herron
comparison [36355 refs] can any one help You correctly test for n==1, but what about when n==2?When the recursion works its way down to fib(2), you call both fib(1) and fib(0), but the latter starts an infinite sequence of calls to fib(-1), fib(-2) and so on without end. Gary Herron -- http

Re: None is None but not working

2017-09-27 Thread Gary Herron
   if data is None: ... and I get output of None None {'MeetingDate': '2017-01- ... and so on. How can I actually get this to check? If i use type(data) I also get None. Cheers Sayth -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: Please Help

2018-01-26 Thread Gary Herron
know what that means?  The answer you might have expected (i.e. 260) does not fit in the 0 ... 255 range of 8 bits, and so the result has overflowed and "wrapped around" to produce 4. Try this for a simpler example of the same: >>> np.uint8(260) 4 Gary Herron -- Dr. Gary

Re: =- and -= snag

2023-03-13 Thread Gary Herron
instead of -=. Isn't it unpythonic to be able to make a mistake like that? Regards, Morten These all mean the same thing, but I don't see a good way to designate the second or third as an error. x = -5 x=-5 x =- 5 Dr. Gary Herron Professor of Computer Science DigiPen Institute of

Re: Standard class for time *period*?

2023-03-27 Thread Gary Herron
The Python standard library module datetime seems to be what you want.  It has objects representing date/times, and deltatimes (i.e., durations).  These can be timezone aware or not as you wish. Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology On 3/27/23 6:00 AM

Re: Change first occurrence of character x in a string - how?

2021-02-14 Thread Gary Herron
requirement of needing to change '.' to '@'. Alternatively is there an RE 'match' function that would test if linux-r...@vger.kernel.org matches linux-raid.vger.kernel.org? I don't really care if the '.' are all regarded as wild cards, the match will

Re: A strange list concatenation result

2016-08-11 Thread Gary Herron
, 6] In this next example, there are two separate lists: >>> list1 = [1,2,3] >>> list2 = [1,2,3] >>> list1 += [4,5,6] >>> print(list1, list2) [1, 2, 3, 4, 5, 6] [1, 2, 3] Does that help? Gary Herron -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: degrees and radians.

2016-08-23 Thread Gary Herron
libraries Just for what its worth. Do you really need anything more complex than this? >>> toRadians = math.pi/180.0 >>> math.sin(90*toRadians) 1.0 Perhaps I'm not understanding what you mean by "clunky", but this seems pretty clean and simple to me. Gary H

Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread Gary Herron
e guesswork: if cv2.rectangle draws a rectangle, what does it return? If it doesn't return anything, the line im = cv2.rectangle(...) is how im gets the value of None. -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread Gary Herron
manual for opencv, we see that cv2.rectangle does indeed return None: Python: cv.Rectangle(img, pt1, pt2, color, thickness=1, lineType=8, shift=0) → None So the first pass through your loop does indeed set im to None with the line im = cv2.rectangle(im.copy(), (x,y), (x+w,

Re: specifying the same argument multiple times with argparse

2018-04-16 Thread Gary Herron
e: >>> >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', action='append') >>> parser.parse_args('--foo 1 --foo 2'.split()) Namespace(foo=['1', '2']) I hope that helps. -- Dr. Gary Herr

Re: Weird side effect of default parameter

2018-05-03 Thread Gary Herron
This is a well known feature of Python.   It's a very common "gotcha" to new Python programmers. Google "Mutable default parameters in Python" for long list of explanations and fixes. In short, don't use a mutable object as a default parameter. Gary Herron

Re: Numpy array

2018-05-20 Thread Gary Herron
second columns alone for x and y respectively. I am confused as to how data[:10] gives the first 10 rows while data[:,0] gives all rows -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: How can an int be '+' with a tuple?

2018-06-02 Thread Gary Herron
the "any + context" at line 18. The "any" was passed as an integer from line 43 and the "context" was defined as a tuple at line 35. This concatenation works! how? Best Regards, Jach Fong --- This email has been checked for viruses by Avast antivirus softwa

Re: curve_fit in scipy

2018-06-19 Thread Gary Herron
_fit(test_func, x_data, y_data, p0=[2, 2]) print(params) plt.figure(figsize=(6, 4)) plt.scatter(x_data, y_data, label='Data') plt.plot(x_data, test_func(x_data, params[0], params[1]), label='Fitted function') plt.legend(loc='best&#

Re: Python Probability

2018-09-11 Thread Gary Herron
table. But its giving me zeros or 333. And to get 5digits after the zero i wanted to use "%.5f " %First. Could you help me to finish this, and tell me what am I doing wrong? Thank you -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895

Re: Python Probability

2018-09-11 Thread Gary Herron
make a table. But its giving me zeros or 333. And to get 5digits after the zero i wanted to use "%.5f " %First. Could you help me to finish this, and tell me what am I doing wrong? Thank you -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895

Re: trying to connect the setarrange and blendshape input target weight while running the script am getting error in the 8th line. (for each in lip_val_list: )

2018-09-13 Thread Gary Herron
lendshape, what's an input target weight,  what does it mean to connect them?  Either none of that is important (as is the case in this simple indentation error), so don't include such distractions, or it does matter, so take the time to define those terms. Gary Herron On

Re: import inspect error

2018-09-17 Thread Gary Herron
You appear to have a local file named keyword.py which is hiding a python installation file of the same name. Gary Herron On 09/17/2018 01:06 AM, jupiter@gmail.com wrote: I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. Python 2.7.15rc1 (default

Re: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1.

2018-10-02 Thread Gary Herron
We're not here to do your homework for you, and you won't learn anything if we do.  You make an attempt at solving this, asking any specific Python related questions you need help with, and you'll find this to be prompt, friendly, and helpful group. Gary Herron -- Dr. Gary

Re: My python code has suddenly started to give me error. Please see code below**

2018-10-08 Thread Gary Herron
t((UL1)/(10**(count-1: B12 B1=(B11,"-",B12,"M") B1 -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: Advice on law firm

2018-10-18 Thread Gary Herron
suits? Sent from Mail for Windows 10 -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: namedtuples anamoly

2018-10-18 Thread Gary Herron
ou destroy the   it so carefully stored in Grade.ID. So now the real question is:  What were you trying to accomplish with the assignment?  Tell us, and let's see if we can find a way to accomplish yor goal without wrecking the internals of the Grade class. Gary Herron it has impact on

Re: what is the difference between one-line-operation and 2-line-operation

2016-04-25 Thread Gary Herron
cond time, the iterator is exhausted and returns no objects. A simpler example: "b" is a map object (iterator), then list(b) is run twice. >>> a = [1,2,3] >>> b = map(lambda e: e+1, a) >>> b >>> list(b) [2, 3, 4] >>> list(b) [] I h

Re: def __init__(self):

2016-04-26 Thread Gary Herron
_ method is the constructor for instances of a class. It is not required, but the situations in which a constructor is not needed are few and unusual. If you don't know object-oriented-programming, then I'd suggest you put that high on your list of things to learn. It's a valuab

Re: def __init__(self):

2016-04-26 Thread Gary Herron
my original answer (that it's the constructor), and suggest ignoring the overly pedantic (and confusing) response to the contrary. -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: Image loading problem

2016-05-21 Thread Gary Herron
Label(win, image=img).pack() return img saved_img = load_img(win) ... Gary Herron -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: Spreading a class over multiple files

2016-06-05 Thread Gary Herron
esult will be essentially the same as if all three methods were defined in MainCLass. Gary Herron -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 My primary use case is when I create a "Model" class to reflect an entire SQL database.

Re: Operator precedence problem

2016-06-06 Thread Gary Herron
", "credits" or "license" for more information. >>> 2 ** 3 ** 2 512 >>> 2 ** (3 ** 2) 512 >>> (2 ** 3) ** 2 64 >>> Here's the relevant documentation page: https://docs.python.org/3/reference/expressions.html Look for "... except

Re: CAD Application

2019-05-06 Thread Gary Herron
it's still available for download. -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing and memory management

2019-07-03 Thread Gary Herron
2156 Koyukuk Drive Fairbanks AK 99775-7320 Work: 907-474-5172 cell: 907-328-9145 -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list

Re: Calculations and Variables

2019-10-31 Thread Gary Herron
uot; % eachPay) I am aiming for the result of 43.6, but somehow get the result of 44.44. (meal cost: 200) (Tip: 9) (people: 5) I seem to do the calculation below, but get different results each time. Total * Percentage Amount / 100 -- Dr. Gary Herron Professor of Computer Science DigiPen Ins

Re: Python Source Code for a HTTP Proxy

2005-09-23 Thread Gary Herron
llothar wrote: >Hello, > >i'm looking for a simple http proxy in python. >Does anybody know about something like this ? > > > Here's a list, maintained by Alan Kennedy, of about 20 proxys written in Python: http://xhaus.com/alan/python/proxies.ht

Re: What do you use as symbols for Python ?

2005-11-10 Thread Gary Herron
D > > Another similar approach that keeps those values together in a single namespace is this (my favorite): class State: OPENED, CLOSED, ERROR = range(3) Then you can refer to the values as State.OPENED State.CLOSED State.ERROR The extra clarity (and slight wordine

Re: weird problem with os.chmod

2005-11-11 Thread Gary Herron
James Colannino wrote: >James Colannino wrote: > > > >>So then I entered the command print 0600, and saw that the >>actual number being output was 384 (why would it output 384?!) >> >> >> >> > >Ok, so further research revealed that 0600 is actually the octal >representation for 384 (which

Re: how to convert between type string and token

2005-11-14 Thread Gary Herron
er results faster. Good luck, Gary Herron enas khalil wrote: > > hello all > when i run the code : > # -*- coding: cp1256 -*- > from nltk.tagger import * > from nltk.corpus import brown > from nltk.tokenizer import WhitespaceTokenizer > # Tokeni

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-04 Thread Gary Herron
shed by the comma. Perhaps being more explicit about the returned tuple would produce what you want. lambda x : (x/60,x%60) Gary Herron > > [EMAIL PROTECTED] ~ $ python > Python 2.4.2 (#1, Nov 18 2005, 19:32:15) > [GCC 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)] on lin

Re: Slicing every element of a list

2005-07-12 Thread Gary Herron
;\t\"') > >This of course worked, but why didn't the first one work. Further why >didn't the first one return an error? > > Dr. Gary Herron Digipen Institute of Technology -- http://mail.python.org/mailman/listinfo/python-list

Re: No newline using printf

2005-09-16 Thread Gary Herron
. Use '%1d' % i to convert your number into a single character string. Use sys.stdout.write to send exactly the characters you want to sys.stdout. Thus: sys.stdout.write('%1d' % i) should do what you want. Dr Gary Herron Digipen Institute of Technology -- http://mail.python.org/mailman/listinfo/python-list

Re: why this error?

2005-03-15 Thread Gary Herron
spencer wrote: Hi, I'm not sure why I can't concatenate dirname() with basename(). Of course you *can* concatenate them, but you're not getting that far. The piece os.path.dirname(os.getcwd) should be os.path.dirname(os.getcwd()) Then it will work without raising an exception, but

Re: Please help with this

2013-11-12 Thread Gary Herron
this group, but the question, as you've asked it, is a misuse (or even an *abuse*) of this group. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Trying to Help a Friend

2013-11-19 Thread Gary Herron
will follow. As a side note, these are extremely simple beginner problems, each requiring only a few lines of code. Any programming class that assigned these must have included some lectures on the basics of programming. That's where he should start. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Trying to Help a Friend

2013-11-21 Thread Gary Herron
ever, the function itself looks correct otherwise, although you may want to start the sequence off with [n] rather than [] so as to match the suggested output. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Trying to Help a Friend

2013-11-21 Thread Gary Herron
ed. Then perhaps we can get to the bottom of this. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Extending the 'function' built-in class

2013-12-01 Thread Gary Herron
you think the function class is, and why are you trying to extend it? Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Eliminate "extra" variable

2013-12-06 Thread Gary Herron
a complete waste of time. In fact, with what you've shown us, you can eliminate the variable dateStrs, and both loops and be no worse off. Perhaps there is more to your code than you've shown to us ... Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: python programming help

2013-12-08 Thread Gary Herron
certainly need a loop (through the dictionary entries), an 'if' conditional to test for the age matching the given age, and a print, Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Script

2013-12-12 Thread Gary Herron
oject", but we don't know what that project is. In fact, I can't even figure out if your trouble is with the script, or with using the script in this unknown project. Also, if you repost, please include the script in the email, not as a pointer to somewhere else. Gary He

Re: Knapsack Problem Without Value

2013-12-12 Thread Gary Herron
ython list. Does your problem have anything to do with Python? * Is this a homework problem? We generally don't solve homework problems here (since you don't learn anything that way), but we are certainly happy to help you learn. Gary Herron -- Dr. Gary Herron Department of Comp

Re: Wrapping around a list in Python.

2013-12-15 Thread Gary Herron
thon is general enough to do what you want, but you'll have to do a much better job telling is what you want. While you are at it, tell us what you've already done, and how it fails to do whatever it is you want. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Pygame vector handling?

2013-12-21 Thread Gary Herron
rk" tells us nothing. What error message, or what incorrect results? * I'm not likely to read your hundred+ lines of code trying to find a bug. Please reduce you question to one or several lines of code, what you expect them to do, and what they are doing that you conside

Re: cascading python executions only if return code is 0

2013-12-22 Thread Gary Herron
On 12/22/2013 10:37 AM, Frank Cui wrote: hey guys, I have a requirement where I need to sequentially execute a bunch of executions, each execution has a return code. the followed executions should only be executed if the return code is 0. is there a cleaner or more pythonic way to do this oth

Re: 2nd Try: Trouble writing lines to file that include line feeds - Newbie

2013-12-23 Thread Gary Herron
the second parameter of the open call. See http://docs.python.org/3/library/functions.html#open for a list of other modes available for the open call. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: How can i return more than one value from a function to more than one variable

2013-12-23 Thread Gary Herron
If you want a function to return several values to several variables, try: def fn(...): # calculate a and b return a,b p,q = fn(...) All these comma-separated sequences are tuples, often written with parentheses as (x,y)=(y,x) and (p,q)=fn(...), but as here, the parentheses

Re: Ifs and assignments

2014-01-02 Thread Gary Herron
nvinced, ... then sorry, that's just the way Python is. Gary Herron handleMatch1(m) elif m = r2.search(w): handleMatch2(m) else: print("No match") If the regular expressions are complex, running them multiple times (once to test, another to capture groups) isn'

Re: Ifs and assignments

2014-01-02 Thread Gary Herron
rry. I shot off my answer before reading the whole post. That's never a good idea. After reading to the end, I rather like your suggestion. It works well in your example, , nicely avoids the C/C++ trap, and has some consistency with other parts of Python. Gary Herron On 02/01/2014

Re: gotta love radio buttons

2014-01-05 Thread Gary Herron
o return an element from the list (indexed by r -- expected to be an integer). Either of these remove the redundancy (but the first is more Pythonic) for r in var: helper = r.get() or for i in range(len(var)): helper = var[i].get() Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: gotta love radio buttons

2014-01-05 Thread Gary Herron
erstanding tracebacks are skills well worth trying to develop. Good luck. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: converting a string to a function parameter

2014-01-05 Thread Gary Herron
t; associated with the same object. That's one object associated with three names in two different namespaces. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: buggy python interpretter or am I missing something here?

2014-01-26 Thread Gary Herron
ould differ slightly, but the advice is the same.) Perh

Re: buggy python interpretter or am I missing something here?

2014-01-26 Thread Gary Herron
On 01/26/2014 10:17 PM, me wrote: On Sun, 26 Jan 2014 21:04:57 -0800, Gary Herron wrote: Never *ever* have a bare except like that. If it gets invoked, you have no idea why. A simple typo like ixd instead of idx or a(idx) instead of a[idx] would raise an exception but give you no idea why

Re: buggy python interpretter or am I missing something here?

2014-01-26 Thread Gary Herron
ksome habit you have there, this jumping to (incorrect) conclusions so quickly. We'd like to get to the bottom of this. (And correct your mis-interpretations while we're at it :-)But we need to see your test *and* the results. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Calculator Problem

2014-02-02 Thread Gary Herron
ke 1 = float(...) don't make sense. It's as if you are trying to change the value of the number one, but that's nonsense. And lines like print('Your Final Result is:', 5 * 6) had better print out 30 (since that is what 5 times 6 is) but that's clearly not what you intended. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: [newbie] copying identical list for a function argument

2014-02-03 Thread Gary Herron
... On the other hand expanding a sequence into individual parameters: fn(*(4*[[1,2,3]])) # note extra * preceding the arg willl be a valid call for def fn(a,b,c,d): ... I'm sure other interpretations of your question are possible. Gary Herron what is the prefered method to real

Re: Calculator Problem

2014-02-03 Thread Gary Herron
On 02/03/2014 10:04 AM, Charlie Winn wrote: On Sunday, February 2, 2014 9:46:24 PM UTC, Gary Herron wrote: ... Sorry, but in fact you did *not* run this program as you claim. It's full of syntax errors. Any attempt to run it will display syntax errors immediately, and never actuall

Re: kivy

2014-02-04 Thread Gary Herron
might find an answer here, but I think you'd have much better luck if you found a kivy specific newsgroup. Good luck, Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'list' object is not callable

2014-02-06 Thread Gary Herron
the time to tell us what line produced that error? That is: cut and paste the *full* traceback instead of hiding useful information when you are asking for help. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Dictionaries

2014-02-08 Thread Gary Herron
as a key, so b[x] works. If a and b had different keys, then you would get an error: >>> a = {'a':1} >>> b = {'b':2} >>> for x in a: ... print x ... print a[x] ... print b[x] ... a 1 Traceback (most recent call last): File "", line 4, in KeyError: 'a' Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Flag control variable

2014-02-11 Thread Gary Herron
tion is how you ran the program in such a manner that sys.argv[3] has such an odd value. What does your command line look like? You didn't tell us, but that's where the trouble is. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Flag control variable

2014-02-11 Thread Gary Herron
ran the program in such a manner that sys.argv[3] has such an odd value. What does your command line look like? You didn't tell us, but that's where the trouble is. Gary Herron how do you meen "what does your command line look like?" When you run this python script, *h

Re: Flag control variable

2014-02-11 Thread Gary Herron
for someone to respond to on this list. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list

Re: Flag control variable

2014-02-11 Thread Gary Herron
ed command and runs Python with the rest of the command line arguments is in control of this. If you can find a way to tell your shell to not expand '*' characters, or find a shell that does not do so, then yes, you can dispense with the back-slash. Gary Herron -- https://mail.python.

  1   2   3   4   5   6   7   8   >