Re: How to pass out the result from iterated function

2008-12-10 Thread Gary Herron
So either way, *something* is returned, and in the case of the recursive call, the innermost result is returned back up through all levels of the recursion. Is that what you wanted? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: initialized list: strange behavior

2008-11-24 Thread Gary Herron
here to obscure things. Try this: Here b is a list that contains three references to a. Modify a, and all three references to a show the modification: a = [1,2,3] b = [a,a,a] a.append(4) b [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] Gary Herron nn=3*[[]] nn

Re: find() a larger string within a smaller string

2008-11-14 Thread Gary Herron
. (And then the problem will most likely be in your expectations, not in the find method.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoiding local variable declarations?

2008-11-13 Thread Gary Herron
] or ... probably other ways can be found ... but what's wrong with you original code? Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

[issue4299] 3.0rc2.msi Install Fails (Error Code 2755)

2008-11-11 Thread Gary VanHorn
New submission from Gary VanHorn [EMAIL PROTECTED]: Where can an error code resource be found? -- components: Installation messages: 75744 nosy: sharksuit severity: normal status: open title: 3.0rc2.msi Install Fails (Error Code 2755) versions: Python 3.0

Re: Python equivalent for C module

2008-10-20 Thread Gary Herron
unexpected, and definitely undesirable. I don't believe it -- send your *actual* code, and we'll all have a look. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org

Re: replace numbers in a string

2008-10-09 Thread Gary Herron
this: import re re.sub('[0-9]', '', ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg) 'ttccatttctggacatgacgtctgtggtttaagctttgtgaaagaatgtgctttgattcg' Gary Herron -- Beema Shafreen -- http

Re: how to get the thighest bit position in big integers?

2008-10-05 Thread Gary Herron
worth a test. If you run timing test, let us know the results. Gary Herron I implemented this the following way: def get_highest_bit_num(r): i = -1 while r 0: r = 1 i = i + 1 return i This works, but it is a very unsatisfying solution, because it is so

Re: Is it possible to get the name of an application ?

2008-10-04 Thread Gary M. Josack
/listinfo/python-list Is sys.argv[0] what you want? If so, then os.path.basename(sys.argv[0]) is probably what you want. Thanks, Gary M. Josack -- http://mail.python.org/mailman/listinfo/python-list

Re: Conditionally subclassing based on Import

2008-10-03 Thread Gary Herron
Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: [BaseHTTPServer/SimpleHTTPServer] Remove Server: header

2008-10-03 Thread Gary M. Josack
you've got ?self.send_header('Server', self.version_string()) in the send_response method of the BaseHTTPRequestHandler class in the BaseHTTPServer module. Long story, short, it's going to be a lot of work to get rid of. [EMAIL PROTECTED] wrote: Hello. I'm using SimpleHTTPServer (work

Re: Inheritance but only partly?

2008-10-02 Thread Gary Herron
// Or some such Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-02 Thread Gary Herron
Gary Herron wrote: process wrote: Let's say I have a class X which has 10 methods. I want class Y to inherit 5 of them. Can I do that? Can I do something along the lines of super(Y, exclude method 3 4 7 9 10) ? -- http://mail.python.org/mailman/listinfo/python-list

Re: list to tuple conversion

2008-10-01 Thread Gary M. Josack
sc wrote: clp: Thanx to a recent thread I am able to have a print string with a variable number of formatters -- what I now lack for the creation of an elegant print statement is a tuple -- following is the code, the last line of which does not work: code #!/usr/bin/python import xml.sax

Re: decent interactive python shell on MS Windows?

2008-10-01 Thread Gary Herron
Googling for them, Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: __buitins__ key added during eval()

2008-09-30 Thread Gary M. Josack
William Purcell wrote: I want to use eval to evaluate wx.TextCtrl inputs. How can I keep python from adding the __builtins__ key to mydict when I use it with eval? Other wise I have to __delitem__('__builtins__') everytime I use eval? mydict = {'a':2,'b':3} eval('a*b',mydict) 6 mydict

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Chris Rebert wrote: On Sun, Sep 28, 2008 at 12:59 PM, sotirac [EMAIL PROTECTED] wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. pre random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) #

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Aaron Castironpi Brady wrote: On Sep 28, 2:59 pm, sotirac [EMAIL PROTECTED] wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. pre random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Gary M. Josack wrote: Aaron Castironpi Brady wrote: On Sep 28, 2:59 pm, sotirac [EMAIL PROTECTED] wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. pre random_number = random.sample

Re: Matrix programming

2008-09-25 Thread Gary Herron
* it is you want! Gary Herron On 9/23/08, *Gary Herron* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: A. Joseph wrote: I need an ebook or tutorial that teach matrix programming. Perhaps you should start here: http://www.catb.org/~esr/faqs/smart-questions.html#intro

Re: Matrix programming

2008-09-23 Thread Gary Herron
A. Joseph wrote: I need an ebook or tutorial that teach matrix programming. Perhaps you should start here: http://www.catb.org/~esr/faqs/smart-questions.html#intro Gary Herron -- http://mail.python.org/mailman

Re: I tried erlang-ish [1|2] in python and something came out...

2008-09-21 Thread Gary Herron
process wrote: In erlang you can cons like this: [1|2]. i tried this in python and it didnt raise an error but i dont know what the result do In Python | is the logical bitwise-OR operator. Look at the binary representation of the numbers to understand it. Gary Herron [1|2

Re: How to make a reverse for loop in python?

2008-09-20 Thread Gary Herron
whatever i -= 1 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Launching a subprocess without waiting around for the result?

2008-09-19 Thread Gary Herron
to register and start a service, and how to stop and remove it later. Google finds lots of information on this -- perhaps I'll post my result when I've pulled it all together. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: member functions in a class

2008-09-18 Thread Gary Herron
answer as to what happens in python? Thanks No code is duplicated. 50 objects are created. Each object has its own copy of the data attributes, and a reference to the (one and only) class object where the method attributes are located. That's a short answer. Perhaps too short? Gary Herron

[issue3829] Tuple comparison masking exception

2008-09-15 Thread Gary Poster
Changes by Gary Poster [EMAIL PROTECTED]: -- nosy: +gary ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3829 ___ ___ Python-bugs-list mailing list

Re: How does python call OS?

2008-09-14 Thread Gary Herron
to write a DLL in C/C++ that calls the function first? Thanks! Siegfried See the ctypes module for a method of calling any C callable function in and DLL. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any nice way to unpack a list of unknown size??

2008-09-14 Thread Gary Herron
srinivasan srinivas wrote: I want to do something like below: 1. first, second, third, *rest = foo Python 3.0 has exactly this feature. No current Python 2.x version has it. Gary Herron 2. for (a,b,c,*rest) in list_of_lists: Please suggest. Thanks, Srini Bring your gang

Re: Python and Open Office

2008-09-12 Thread Gary Herron
this helps, Gary Herro -- http://mail.python.org/mailman/listinfo/python-list

exit()

2008-09-08 Thread Gary Robinson
reason to use sys.exit() given exit()'s availability? If there is an advantage to sys.exit() over exit(), then does sys.exit() have any advantage over raise SystemExit, 'some error message' in cases where a module has no other reason to import sys? -- Gary Robinson CTO Emergent Music, LLC

Re: How do I set a callback in Python?

2008-09-08 Thread Gary Herron
. Hoping I understood what you wanted correctly, Gary Herron ... but obviously, the Client class, when it calls the callback, doesn't pass a reference to the self object. How do I do this? -- Chris -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman

Re: Cathing several potential errors?

2008-09-06 Thread Gary Josack
cnb wrote: if i do try: something except TypeError, IndexError: pass only the first error will get caught. I dont want to use Exception and catch all errors, but just 2. how can i do that? -- http://mail.python.org/mailman/listinfo/python-list what you're doing is assigning the

Re: File operations

2008-08-21 Thread Gary Herron
aditya shukla wrote: Hello guys I am trying to search a file say xyz.txt after searching i get the location of the file in search_file (containing abspath) ,eg search_file=c:\\abc\\xyz.txt now how should i open this file i can use file=open(c:\\abc\\xyz.txt,rb) but i have to use search_

Re: Is there a faster way to do this?

2008-08-05 Thread Gary Herron
... IDs = set(extractIdFromRow(row) for row in rowsOfTable) or some such would be most efficient. Gary Herron Heres the code: import string def checkForProduct(product_id, product_list): for product in product_list: if product == product_id: return 1 return 0

Re: Is there a faster way to do this?

2008-08-05 Thread Gary Herron
chunks (efficiently) and then serves up the contents line-by-line. Gary Herron If you use a dictionary and search the ID's there, you'll notice some speed improvements as Python does a dictionary lookup far quicker than searching a list. Then, output your data all at once at the end

Re: xlrd

2008-08-04 Thread Gary Herron
, so you get a zero. Should you be asking for a string value? (That's the way OpenOffice/python works if I remember correctly.) Or are you accessing a different cell because you've confused 0-based / 1-based indexing? Or are you using old outdated versions of xlrd, Python or Excel? Gary

Re: What Python looks like

2008-08-04 Thread Gary Herron
a program???) My impression was (and still is): A page of Python code looks *clean*, with not a lot of punctuation/special symbols and (in particular) no useless lines containing {/} or begin/end or do/done (or whatever). Gary Herron Thanks -- http://mail.python.org/mailman/listinfo/python

Re: Searching for some kind of data type

2008-08-02 Thread Gary Herron
to), ... ] ftpCommands = {} for cmd,args in cmd_data.iteritems(): ftpCommands[cmd] = CommandProperty(*args) Gary Herron IMHO this is a little easier to manage because you can take advantage of the default values for keyword arguments to eliminate some of the arguments. Hope this helps, Larry -- http

Re: Continually check object status

2008-08-02 Thread Gary Herron
state external to the program (file content, socket data, phase of the moon, price of tea in China, ...) Each of those possibilities would require a substantially different approach. Gary Herron I might be approaching this from the wrong direction entirely. Thanks for your input. -- http

Re: Proxy server?

2008-07-30 Thread Gary
Diez B. Roggisch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Gary schrieb: Diez B. Roggisch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] You can't make any TCP/IP communication run through a proxy, unless it's transparent. Thanks for all the info. I'm puzzled

Re: Pointers/References in Python?

2008-07-30 Thread Gary Herron
, it is referred to many times. a = HeavyObject() b = a A = [a,b] B = [b,a] C = set([a,b]) D = {1:a, 2:b} ... and do on Implementation wise, a long list consumes about 4 bytes per list element (that's one address per), plus a tine amount of overhead. Gary Herron I know there is a thing called

Re: overriding file.readline: an integer is required

2008-07-30 Thread Gary Herron
) # etc., etc. I tested this (just barely), and it seems to work as you wish. Gary Herron TIA! Kynn -- http://mail.python.org/mailman/listinfo/python-list

Re: Overloaded Functions

2008-07-29 Thread Gary Herron
, and even their values, before calling __sign_auth(...). Gary Herron Tim Henderson -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Proxy server?

2008-07-28 Thread Gary
I've seen examples for HTTP and FTP use, but not for simply any TCP data on any port, which is what I require. Can anyone please point me in the right direction? TIA -- http://mail.python.org/mailman/listinfo/python-list

Re: python lists and newline character

2008-07-28 Thread Gary Herron
this list without the newline characters being added. or somehow remove the newline characters. Any help would be appreciated. The problem has nothing to do with lists. The readlines() function returns each line *with* its newline. To strip it off, use line.strip() Gary Herron

Re: Proxy server?

2008-07-28 Thread Gary
Diez B. Roggisch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Gary wrote: For what? A non-transparent proxy, for anonymity purposes only. -- http://mail.python.org/mailman/listinfo/python-list

Re: seemingly simple list indexing problem

2008-07-28 Thread Gary Herron
Guilherme Polo wrote: On Mon, Jul 28, 2008 at 6:24 PM, Ervan Ensis [EMAIL PROTECTED] wrote: My programming skills are pretty rusty and I'm just learning Python so this problem is giving me trouble. I have a list like [108, 58, 68]. I want to return the sorted indices of these items in the

Re: derivative in numpy

2008-07-28 Thread Gary Herron
? Gary Herron Cheers, Kim -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: How to figure out if the platform is 32bit or 64bit?

2008-07-28 Thread Gary Josack
Trent Mick wrote: Manuel Vazquez Acosta wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Just test for maxint value: from sys import maxint if maxint 33: print more than 32 bits # probably 64 else: print 32 bits I believe that was already suggested in this thread. That test

Re: python lists and newline character

2008-07-28 Thread Gary Josack
Gary Herron wrote: Support Desk wrote: Hello all, I am using os.popen to get a list returned of vpopmail users, something like this x = os.popen('/home/vpopmail/bin/vuserinfo -n -D mydomain.com).readlines() x returns a list, of usernames, and I am trying to append

Re: exec(code) not allowing import on top level?

2008-07-28 Thread Gary Herron
it.Second, if I exend your string with one more line foo(123) to actually execute the code, it still works as expected. So let's try this again... and this time please please also show us the full text of the error message. Gary Herron and i run it using exec(code) in python, math is not known

Re: exec(code) not allowing import on top level?

2008-07-28 Thread Gary Herron
it.Second, if I extended your string with one more line foo(123) to actually execute the code, it still works as expected. So let's try this again... and this time please please also show us the full text of the error message. Gary Herron and i run it using exec(code) in python, math

Re: Rant (was Re: x*x if x10

2008-07-27 Thread Gary Herron
to False then you can use just this: C and A or B Gary Herron And while I'm on my high horse, I'd like to bring up list concatenations. I recently needed to concatenate 5 lists, which doesn't sound a particularly rare requirement to me. My first attempt was a straightforward loop extending

Re: Rant (was Re: x*x if x10

2008-07-27 Thread Gary Herron
] sum([A,B,C], []) [1, 2, 3, 4, 5, 6, 7, 8, 9] It doesn't get any easier than that. Gary Herron DaveM -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Where is the correct round() method?

2008-07-27 Thread Gary Herron
be representable exactly. However, as with any floating point calculations, if you expect exact representation or calculations with any numbers, then you are misusing floating points. Gary Herron I would think this is a common need, but I cannot find a function in the Python library to do

Re: Where is the correct round() method?

2008-07-27 Thread Gary Herron
) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Path issues

2008-07-26 Thread Gary Josack
://mail.python.org/mailman/listinfo/python-list sys.path is a list that will tell you where python is looking. You can append to this in your scripts to have python look in a specific directory for your own modules. Thanks, Gary M. Josack -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Path issues

2008-07-26 Thread Gary Josack
Brett Ritter wrote: On Jul 26, 2:57 pm, Gary Josack [EMAIL PROTECTED] wrote: sys.path is a list that will tell you where python is looking. You can append to this in your scripts to have python look in a specific directory for your own modules. I can, but that is almost certainly

Re: How to find processes from Python

2008-07-25 Thread Gary Josack
Cameron Simpson wrote: On 25Jul2008 11:34, Johny [EMAIL PROTECTED] wrote: | Is there a way how to find out running processes?E.g. how many | Appache's processes are running? See the popen function and use the ps system command. Use of the popen functions is generally discouraged since being

Re: Reading a file

2008-07-24 Thread Gary Herron
. What method *did* you use to print? If you just typed the variable into which you had read the contents, then you get the equivalent of print repr(c) which explains the escapes. Try print c and that won't happen. Gary Herron ie my output should be d|fj|dnv|jd|0.33|c:\\windows\\win32

Re: string[i:j:k]

2008-07-22 Thread Gary Herron
and go to n-1(where n-len(s)) (it does not mean start at zero and go to -1) So since the indexing is counting upward, the step size had better be positive. Thus: s = '123456789' s[:-1:2] '1357' Gary Herron '' though I expected something like '8642' What did i missed? -- http

Re: Converting List of String to Integer

2008-07-21 Thread Gary Herron
Samir wrote: On Jul 21, 3:20 pm, Gary Herron [EMAIL PROTECTED] wrote: Samir wrote: Hi Everyone, I am relatively new to Python so please forgive me for what seems like a basic question. Assume that I have a list, a, composed of nested lists with string representations

Re: Any Game Developers here?

2008-07-18 Thread Gary Herron
active new groups.) Pygame: http://www.pygame.org/news.html Pyglet: http://pyglet.org/ Gary Herron ~Michael -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: unpacking with default values

2008-07-17 Thread Gary Herron
tuple of arguments to the correct length so you can do: a,c,b = fix(1,2) d,e,f = fix(1,2,3,4) However, the function won't know the length of the left hand side sequence, so it will have to be passed in as an extra parameter or hard coded. Gary Herron -- http://mail.python.org/mailman

Re: properly delete item during for item in...

2008-07-17 Thread Gary Herron
with the for loop's indexing through the list, causing the loop to mis the element following the deleted item. Gary Herron I am not sure if this question even makes any sense anymore. I've been using python for years and never had any problems (and I don't now either) but now that I had

Re: unpacking with default values

2008-07-17 Thread Gary Herron
McA wrote: On 17 Jul., 18:33, Gary Herron [EMAIL PROTECTED] wrote: In Python 2.x, you can't do that directly, but you should be able to create a function that lengthens or shortens an input tuple of arguments to the correct length so you can do: a,c,b = fix(1,2) d,e,f = fix(1,2,3,4

Re: properly delete item during for item in...

2008-07-17 Thread Gary Herron
Ratko wrote: On Jul 17, 9:57 am, mk [EMAIL PROTECTED] wrote: Gary Herron wrote: You could remove the object from the list with del myList[i] if you knew i. HOWEVER, don't do that while looping through the list! Changing a list's length will interact badly with the for loop's indexing

Re: Angle brackets in command-line arguments?

2008-07-16 Thread Gary Herron
shells will provide similar functionality using a variety of similar syntaxes: , , , and |, and so on. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: how to match whole word

2008-07-15 Thread Gary Herron
might be your definition of) a word, and in particular will match abc in :abc:. Regular expressions have lots of other special \-sequences that might be worth your while to read about: http://docs.python.org/lib/re-syntax.html Gary Herron -- http://mail.python.org/mailman/listinfo/python

Re: Someone enlightened me

2008-07-13 Thread Gary Herron
-in-python Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Mutually referencing imports -- impossible?

2008-07-13 Thread Gary Herron
of module ABC has not progressed to the point that abc is defined. The solution: Just import ABC and later reference ABC.abc That being said, it is still a good design practice to structure your modules hierarchically rather than a circularly. Gary Herron -- http://mail.python.org/mailman

Re: Can anyone suggest a date peocedure...

2008-07-10 Thread Gary Herron
exactly one day ago: from datetime import * datetime.today() datetime.datetime(2008, 7, 10, 13, 38, 48, 279539) datetime.today()-timedelta(1) datetime.datetime(2008, 7, 9, 13, 38, 50, 939580) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Can anyone suggest a date peocedure...

2008-07-10 Thread Gary Herron
RV wrote: On Thu, 10 Jul 2008 13:39:29 -0700, Gary Herron [EMAIL PROTECTED] wrote: The datetime module has what you need. It has methods (with examples) on building a datetime object from a string, and it has a object named timedelta, and the ability to subtract a timedelta from a time

Re: Opening Unicode files

2008-07-09 Thread Gary Herron
assigned into it: codecs = ...something overwriting the module object ... Gary Herron I wonder if I need to do something before using the codecs library from within the cgi module?! Thank you very much for your help, Nora

Re: No Exceptions

2008-07-08 Thread Gary Herron
looking carefully throughout the code. Gary Herron Thank you, Robert -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: inconsistency?

2008-07-07 Thread Gary Herron
differences (mutability, sorting and other methods, types of individual elements), I'd say there are more differences than similarities, even though, as sequences, they both support a small subset of similar operations. Gary Herron David C. Ullrich wrote: Luckily I tried it before saying

Re: dynamically load from module import xxx

2008-07-02 Thread Gary Duzan
for it. Good luck. Gary Duzan Motorola HNM -- http://mail.python.org/mailman/listinfo/python-list

Re: Attribute reference design

2008-07-01 Thread Gary Herron
chamalulu wrote: On Jul 1, 11:24 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: chamalulu schrieb: Hello. I think I'm aware of how attribute access is resolved in python. When referencing a class instance attribute which is not defined in the scope of the instance, Python looks for a

Re: Attribute reference design

2008-07-01 Thread Gary Herron
chamalulu wrote: On Jul 2, 1:17 am, Gary Herron [EMAIL PROTECTED] wrote: No need. Also, you can define a class attribute (C++ might call it a static attribute) and access it transparently through an instance. class C: aClassAttribute = 123 def __init__(self, ...): ... c = C

Re: 2D online multiplayer framework?

2008-06-28 Thread Gary Herron
/mailman/listinfo/python-list Pyglet is my favorite: http://www.pyglet.org/ Twisted might be fine for the online multiplayer parts, but really if you want a 2D/3D real-time game, start with a game framework. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Use of the is statement

2008-06-27 Thread Gary Herron
: *never* use is. (A longer answer can find some uses cases for is, but stick with the short answer for now.) Gary Herron Python 2.5.2 'string' is 'string' #simple assignment works True s = 'string' s is 'string' True def make_string(): return 'test

Re: where is the error?

2008-06-26 Thread Gary Herron
thing: Find out what value that index has, then if it's necessary to ask your question again, include that information and we'll have something to go on in forming an answer. Gary Herron I have this error message: IndexError: each subindex must be either a slice, an integer, Ellipsis

Re: I Need A Placeholder

2008-06-26 Thread Gary Herron
Gary Herron The only problem is if I leave a comment only in the except block, I get an error back saying that the except block is not properly formatted, since it has no content other than a comment. So if anyone could suggest some code to put there as a placeholder that would be wonderful

Re: How to import filenames with special characters?

2008-06-24 Thread Gary Herron
and the standard module named imp. Gary Herron * * -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing arguments to subclasses

2008-06-23 Thread Gary Herron
python-list. Like this: class ParentClass(object): ... def __init__(self, keyword1, keyword2): ... print 'ParentClass.__init__ called with', keyword1, keyword2 ... class ChildClass(ParentClass): ... pass ... child = ChildClass(123,456) ParentClass.__init__ called with 123 456 Gary

32-bit python memory limits?

2008-06-23 Thread Gary Robinson
limit wrong? I guess so! But I'm pretty sure I saw it max out at 2GB on linux... Anybody have an explanation, or is it just that my understanding of a 2GB limit was wrong? Or was it perhaps right for earlier versions, or on linux...?? Thanks for any thoughts, Gary -- Gary Robinson CTO Emergent

Re: -1/2

2008-06-22 Thread Gary Herron
Serve Lau wrote: What is the expected result of -1/2 in python? -- http://mail.python.org/mailman/listinfo/python-list From the manual: The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Gary Herron -- http://mail.python.org

Re: -1/2

2008-06-22 Thread Gary Herron
Christian Heimes wrote: Serve Lau wrote: What is the expected result of -1/2 in python? 0 No. That's not right. (It would be in C/C++ and many other languages.) See my other response for the correct answer. Gary Herron Christian -- http://mail.python.org/mailman

Re: Python is behavior

2008-06-20 Thread Gary Herron
is a trade off (like any caching scheme) of cache-space versus efficiency gains. The value has changed at least once in recent versions of Python. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Ternary operator alternative in Ptyhon

2008-06-18 Thread Gary Herron
. self.SomeField = params[mykey] if params.has_key(mykey) else None Gary Herron Obviously I know this is not actual Python syntax, but what would be the equivalent? I'm trying to avoid this, basically: if params.has_key(mykey): self.SomeField = params[mykey] else

Re: Another (perhaps similar) import question

2008-06-13 Thread Gary Herron
of this is a stupid question) Not stupid. It will all start making sense soon. Gary Herron Dan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

Re: Another (perhaps similar) import question

2008-06-13 Thread Gary Herron
? No. Conclusion: Don't use reload (ever). A dozen years of Python programming, and I've never used it even once. If there is a good use case for reload, you are probably years from being there. Gary, thanks very much for your help.I suspected it was something like this. I still can quite

Re: howto split string with both comma and semicolon delimiters

2008-06-12 Thread Gary Herron
function that does what you want. import re r =',|;' # or this also works: '[,;]' s = a,b;c re.split(r,s) ['a', 'b', 'c'] Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find duplicate 3d points?

2008-06-11 Thread Gary Herron
) or so. Happy google-ing and good luck. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

proposal: give delattr ability to ignore missing attribute

2008-06-10 Thread Gary Wilson
AttributeError: pass or: try: del obj.foo except AttributeError: pass or: if hasattr(obj, 'foo') delattr(obj, 'foo') For backwards compatibility, allow_missing would default to False. Gary -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I find out (dynamically) where a method is defined?

2008-06-09 Thread Gary Herron
of information about a method (even including the file name and line number where it was defined). Poke around and perhaps you can find exactly what you are looking for. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Separators inside a var name

2008-06-09 Thread Gary Herron
Rainy wrote: I have a stylistic question. In most languages words in var. name are separated by underscores or cap letters, resulting in var names like var_name, VarName and varName. I don't like that very much because all 3 ways of naming look bad and/or hard to type. From what I understand,

Re: Can this be done with list comprehension?

2008-06-07 Thread Gary Herron
Karlo Lozovina wrote: This is what I'm trying to do (create a list using list comprehesion, then insert new element at the beginning of that list): result = [someFunction(i) for i in some_list].insert(0, 'something') But instead of expected results, I get None as `result`. If instead of

Re: Change in interactive interpreter?

2008-06-06 Thread Gary Herron
to enable it? Thanks! Try again. I think you'll find it's still there -- although you have to execute a something that returns a value before it's set for the first time. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning which modules were loaded

2008-06-06 Thread Gary Herron
all the imported modules, but I suspect you'll find that it's much easier to let py2app and py2exe determine what's imported than it is to go through sys.modules yourself. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   10   >