Re: Request for help
On 2016-07-19 22:21, alister wrote: On Tue, 19 Jul 2016 13:06:39 +1000, Steven D'Aprano wrote: On Tue, 19 Jul 2016 06:20 am, alister wrote: I suggest next time you stay awake during lessons. That's an uncalled for nasty comment. You don't know the O.P's issues or why he is having difficulty. because he has failed to provide any context. the question as phrased looks exactly like a homework question a tutor would set after a lesson introducing classes It looked a lot like some posts from earlier this year. -- https://mail.python.org/mailman/listinfo/python-list
Re: Request for help
On Tue, 19 Jul 2016 13:06:39 +1000, Steven D'Aprano wrote: > On Tue, 19 Jul 2016 06:20 am, alister wrote: > >> I suggest next time you stay awake during lessons. > > That's an uncalled for nasty comment. You don't know the O.P's issues or > why he is having difficulty. because he has failed to provide any context. the question as phrased looks exactly like a homework question a tutor would set after a lesson introducing classes -- If you keep anything long enough, you can throw it away. -- https://mail.python.org/mailman/listinfo/python-list
Re: Request for help
On Mon, 18 Jul 2016 07:50 pm, Eric kago wrote: > Hi Pythoners > > I need help in understanding hoe to put up the code to the following > command Hi Eric, You might find that the "Tutor" mailing list is better for simple questions like this: https://mail.python.org/mailman/listinfo/tutor Remember, for help with home work, show the code you already have. >- Create a constructor that takes in an integer and assigns this to a >`balance` property Talking about a "constructor" means that you need to have a class. We define a class with the "class" keyword: class Myclass: pass To give it a constructor method, you need to use the __init__ method, or sometimes __new__. In this case, I think __init__ is what you want. Do you know how to define methods inside a class? Remember that __init__ is spelled with TWO underscores at the start and end. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: Request for help
On Tue, 19 Jul 2016 06:20 am, alister wrote: > I suggest next time you stay awake during lessons. That's an uncalled for nasty comment. You don't know the O.P's issues or why he is having difficulty. -- Steven “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: Request for help
On Mon, 18 Jul 2016 12:50:04 +0300, Eric kago wrote: > Hi Pythoners > > I need help in understanding hoe to put up the code to the following > command > > >- Create a constructor that takes in an integer and assigns this to a >`balance` property > > > > > Regards, > > Eric Kago +254(0)714249373 Nairobi Kenya I suggest next time you stay awake during lessons. -- I treasure this strange combination found in very few persons: a fierce desire for life as well as a lucid perception of the ultimate futility of the quest. -- Madeleine Gobeil -- https://mail.python.org/mailman/listinfo/python-list
Re: Request for help
Hi Pythoners I need help in understanding hoe to put up the code to the following command - Create a constructor that takes in an integer and assigns this to a `balance` property Regards, Eric Kago +254(0)714249373 Nairobi Kenya -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 12:56:03 -0600, Wildman wrote: > On Tue, 01 Mar 2016 19:26:55 +0100, Peter Otten wrote: > >> An exception is raised because you pass the command as a single argument > > > > I did not realize that how the command was passed would > make such a difference. I guess I am stuck in my old > VB habits for creating variables. You don't have to > say it, this ain't VB! :-) > > After making the changes to "command = ", it works fine > without the shell. At the risk of sounding redundant, > thank you. Ok, after some thought I think I understand what happened. Since I had the command as a single element, bash was required to parse the command therefore my code would not run without shell=true. That makes sense. I may not be the fastest oar in the water but I will eventually reach the shore. Thanks again for all your help. -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 20:30:59 +0100, Christian Gollwitzer wrote: > Am 29.02.16 um 22:51 schrieb Wildman: >> I want to take an image file, convert it to XBM format and >> display it. Thanks to Mr. Otten I can open and display the >> XBM image without any problems. The script first calls an >> external program for the image conversion then I can open >> and display it. Of course, I am left with the XBM file that >> needs to be deleted. > > I think you are solving the wrong problem. If your aim is to just > display an image using Tkinter, you can use PIL to read the image and > transfer the bits into a Tkinter photoimage object. For an example, look > here: > > http://code.activestate.com/recipes/521918-pil-and-tkinter-to-display-images/ > > (this might need some updating if you are using Python 3) > > Christian Thanks. I have read that page, among many others, during my research. It deals with an actual image file. I am dealing with an image that is not a file. It was redirected to stdout from another process and was never saved to the hard drive. Anyway, with Mr. Otten's help the problem is resolved. -- GNU/Linux user #557453 "Real patriotism is a willingness to challenge the government when it's wrong." -Ron Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
Am 29.02.16 um 22:51 schrieb Wildman: I want to take an image file, convert it to XBM format and display it. Thanks to Mr. Otten I can open and display the XBM image without any problems. The script first calls an external program for the image conversion then I can open and display it. Of course, I am left with the XBM file that needs to be deleted. I think you are solving the wrong problem. If your aim is to just display an image using Tkinter, you can use PIL to read the image and transfer the bits into a Tkinter photoimage object. For an example, look here: http://code.activestate.com/recipes/521918-pil-and-tkinter-to-display-images/ (this might need some updating if you are using Python 3) Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 19:26:55 +0100, Peter Otten wrote: > An exception is raised because you pass the command as a single argument I did not realize that how the command was passed would make such a difference. I guess I am stuck in my old VB habits for creating variables. You don't have to say it, this ain't VB! :-) After making the changes to "command = ", it works fine without the shell. At the risk of sounding redundant, thank you. -- GNU/Linux user #557453 "The Constitution only gives people the right to pursue happiness. You have to catch it yourself." -Benjamin Franklin -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
Wildman via Python-list wrote: > On Tue, 01 Mar 2016 09:56:56 +0100, Peter Otten wrote: >> Wildman via Python-list wrote: >>> convert = "convert " + fileName + " -resize 48x48! -threshold 55% xbm:-" >>> p = subprocess.Popen([convert], stdout=subprocess.PIPE, shell=True) >>> xbmFile, err = p.communicate() >> Why would you need a shell? Just in case the example in my previous post has not made it clear: that was a rhetorical question. You do not need the shell, and in fact shouldn't use it. > I guess it is a Linux thing. If I don't use it, I get > the below error. A shell window does not actually open. > I presume it runs in the background while executing the > subprocess command. > Exception in Tkinter callback > Traceback (most recent call last): > File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__ > return self.func(*args) > File "./test.py", line 59, in open_image > p = subprocess.Popen(command, stdout=subprocess.PIPE) > File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ > errread, errwrite) > File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory An exception is raised because you pass the command as a single argument like in [Python 2.7] >>> subprocess.Popen("ls /usr/share/dict/words") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory This looks for an executable called "ls /usr/share/dict/words" (the whole shebang!) where you actually want to run "ls" with the argument "/usr/share/dict/words". Once you split the parts >>> subprocess.Popen(["ls", "/usr/share/dict/words"]) >>> /usr/share/dict/words everything works as expected. The error message in Python 3.4 would have given you a clue, by the way: [Python 3.4] >>> subprocess.Popen("ls /usr/share/dict/words") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.4/subprocess.py", line 859, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'ls /usr/share/dict/words' -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 09:56:56 +0100, Peter Otten wrote: > Wildman via Python-list wrote: > >> I want to take an image file, convert it to XBM format and >> display it. Thanks to Mr. Otten I can open and display the >> XBM image without any problems. The script first calls an >> external program for the image conversion then I can open >> and display it. Of course, I am left with the XBM file that >> needs to be deleted. It seemed to me to be a better approach >> to use stdout and pipe thereby eliminating the XBM file >> altogether. Here is code I have so far but I'm not sure >> what to do next... >> >> convert = "convert " + fileName + " -resize 48x48! -threshold 55% xbm:-" >> p = subprocess.Popen([convert], stdout=subprocess.PIPE, shell=True) >> xbmFile, err = p.communicate() > > Why would you need a shell? I guess it is a Linux thing. If I don't use it, I get the below error. A shell window does not actually open. I presume it runs in the background while executing the subprocess command. Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__ return self.func(*args) File "./test.py", line 59, in open_image p = subprocess.Popen(command, stdout=subprocess.PIPE) File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory >> The variable fileName contains the image file path and name. >> The variable convert contains the complete command. The last >> argument in the command tells the convert utility to covert >> to an XBM and to direct the output to stdout. After the above >> code runs xbmFile contains the actual image, which is plain >> text. (X BitMap (XBM) is a plain text binary image format.) >> >> My question is how do I take the xbmFile variable and convert >> it to an image object that can be displayed? The technique >> for displaying an image from a file does not work or at least >> I have not been able to get it to work. > > I think Image.open() accepts a file-like object, so > > import io > ... > command = [ > "convert", fileName, > "-resize", "48x48!", > "-threshold", "55%", > "xbm:-"] > p = subprocess.Popen(command, stdout=subprocess.PIPE) > xbmFile, err = p.communicate() > openImage = Image.open(io.BytesIO(xbmFile)) > > should work. I does work, perfectly. During my research I didn't run across anything about using io. The learning process continues... I am in your debt again. Thank you. -- GNU/Linux user #557453 "Be at war with your vices, at peace with your neighbors, and let every new year find you a better man." -Benjamin Franklin -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
Wildman via Python-list wrote: > I want to take an image file, convert it to XBM format and > display it. Thanks to Mr. Otten I can open and display the > XBM image without any problems. The script first calls an > external program for the image conversion then I can open > and display it. Of course, I am left with the XBM file that > needs to be deleted. It seemed to me to be a better approach > to use stdout and pipe thereby eliminating the XBM file > altogether. Here is code I have so far but I'm not sure > what to do next... > > convert = "convert " + fileName + " -resize 48x48! -threshold 55% xbm:-" > p = subprocess.Popen([convert], stdout=subprocess.PIPE, shell=True) > xbmFile, err = p.communicate() Why would you need a shell? > The variable fileName contains the image file path and name. > The variable convert contains the complete command. The last > argument in the command tells the convert utility to covert > to an XBM and to direct the output to stdout. After the above > code runs xbmFile contains the actual image, which is plain > text. (X BitMap (XBM) is a plain text binary image format.) > > My question is how do I take the xbmFile variable and convert > it to an image object that can be displayed? The technique > for displaying an image from a file does not work or at least > I have not been able to get it to work. I think Image.open() accepts a file-like object, so import io ... command = [ "convert", fileName, "-resize", "48x48!", "-threshold", "55%", "xbm:-"] p = subprocess.Popen(command, stdout=subprocess.PIPE) xbmFile, err = p.communicate() openImage = Image.open(io.BytesIO(xbmFile)) should work. -- https://mail.python.org/mailman/listinfo/python-list
Re: request for help
Is this exactly how it shows in your shell? If so, it seems you need to indent your methods. # import math def area(radius): return math.pi * radius**2 def circumference(radius): return 2 * math.pi * radius # *Matt Jones* On Mon, Feb 18, 2013 at 1:42 PM, leonardo selmi l.se...@icloud.com wrote: pls i need help: i have copied the following from a book and tried to make it work: import math def area(radius): return math.pi * radius**2 def circumference(radius): return 2 * math.pi * radius i saved the above program from python shell into a file as circle.py . when i type import circle i get error.. kind regards -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: request for help
leonardo selmi l.selmi at icloud.com writes: [...] i saved the above program from python shell into a file as circle.py . when i type import circle i get error.. Urm... would you be so kind as to copy and paste the error message verbatim? You have obvious syntax errors in this code due to improper indentation, but take a word of advice from the Python Zen: In the face of ambiguity, refuse the temptation to guess So let's have a look-see at that error message, shall we? -- http://mail.python.org/mailman/listinfo/python-list
Re: request for help
On 02/18/2013 11:42 AM, leonardo selmi wrote: pls i need help: i have copied the following from a book and tried to make it work: import math def area(radius): return math.pi * radius**2 def circumference(radius): return 2 * math.pi * radius i saved the above program from python shell into a file as circle.py . when i type import circle i get error.. kind regards First, you shouldn't ask us to help you fix an error without telling us what the error is! You should also tell us what version of Python and what system (Windows? Linux? ...) , and anything more that can help us understand what you did and what failed. So this is just guesswork: Spaces are important in Python. The body of a function **must** be indented. If you do have the indents in your code, and they were just lost in the process of cutting and pasting and emailing, the we really do need more information. def area(radius): return math.pi * radius**2 def circumference(radius): return 2 * math.pi * radius -- http://mail.python.org/mailman/listinfo/python-list
Re: request for help
Leonardi, i saved the above program from python shell into a file as circle.py . when i type import circle i get error.. Next time, please mention what kind of error you're getting. Was it an indentation error? Because, as you pasted it, your code would lead to one. If I fix the indentation, as in import math def area(radius): return math.pi * radius**2 def circumference(radius): return 2 * math.pi * radius it works fine for me. HTH, Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: request for help
thanks guys and sorry for my incomplete datas, here is the error message: Traceback (most recent call last): File pyshell#0, line 1, in module import circle File circle.py, line 1 Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43) ^ SyntaxError: invalid syntax thanks for any help! Il giorno 18/feb/2013, alle ore 20:59, Stefan Holdermans ste...@vectorfabrics.com ha scritto: Leonardi, i saved the above program from python shell into a file as circle.py . when i type import circle i get error.. Next time, please mention what kind of error you're getting. Was it an indentation error? Because, as you pasted it, your code would lead to one. If I fix the indentation, as in import math def area(radius): return math.pi * radius**2 def circumference(radius): return 2 * math.pi * radius it works fine for me. HTH, Stefan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: request for help
On 02/18/2013 12:14 PM, leonardo wrote: thanks guys and sorry for my incomplete datas, here is the error message: Traceback (most recent call last): File pyshell#0, line 1, in module import circle File circle.py, line 1 Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43) ^ SyntaxError: invalid syntax If I read this error message correctly, I don't think the contents of circle.py are at all what you claim. It looks like the first line of circle.py contains the text Python 2.7.3 ... which is certainly not what you intended or claimed. Please examine the contents of circle.py very carefully. thanks for any help! Il giorno 18/feb/2013, alle ore 20:59, Stefan Holdermans ste...@vectorfabrics.com ha scritto: Leonardi, i saved the above program from python shell into a file as circle.py . when i type import circle i get error.. Next time, please mention what kind of error you're getting. Was it an indentation error? Because, as you pasted it, your code would lead to one. If I fix the indentation, as in import math def area(radius): return math.pi * radius**2 def circumference(radius): return 2 * math.pi * radius it works fine for me. HTH, Stefan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: request for help
leonardo tampucciolina at libero.it writes: here is the error message: [...] Okay, now we are on the road to solving this problem. But first we need to take a slight detour and learn about python packaging, because no matter what the current error is, naming a module circle and then throwing it naked out into the Python module wilderness is complete folly; i can assure you! What is a Python package? A python package is simply another layer of namespace that protects our symbols from clashing; in this case: module identifiers. Even noobs understand that function bodies and class bodies (bka: object definitions) protect code from outside influences, and that modules protect the symbols contained in one module from the symbols contained in /other/ modules, however, we still must protect module identifiers somehow. How do we do this? Packages to the rescue! Your circle.py module needs to be under the protective care of a specialized package named geom2d , which itself should be under the care of a specialized package named math, which itself should be under the global blanket of a personal library package named insertUniqueNameHere! This is how we protect module symbols whilst simultaneously employing a logical structure in our code. Impatient Ivan exclaimed: So how the heck do i create the package Rick? Steps to create the entire package hierarchy: Note: All package and modules names should be lowercase! 1a. Create a folder named mylib on the Python search path. 1b. Convert the mylib folder into a package by adding a file named: __init__.py This will be your personal package for containing your personal modules. 2a. Inside the mylib folder create another folder called math 2b. Convert the mylib\math folder to a package by adding a file named __init__.py. 3a. Inside the mylib\math folder create another folder named geom2d 3b. Convert the mylib\math\geom2d folder to a package by adding a file named __init__.py. 4. Inside the mylib\math\geom2d folder create a new file named circlelib.py. This is where you will place the code for computing circle data. Later you will probably write something more useful, but for now this module is the best you have. Now, you'll need to import the circlelib for use and this is how you do it: ## START CODE ## from mylib.math.geom2d.circlelib import area, circumference area(blah) circumference(blah) ## END CODE ## From now on, if you create any more modules that deal with maths (or a subset of math: geom) you have a place to store them intelligently. There is quite a bit more to Python packages but what i describe above is the most fundamental aspect. Back to your exception Did correcting the indentation fix the problem? If not, what is the next error you get? -- http://mail.python.org/mailman/listinfo/python-list
Re: request for help
On 2/18/2013 2:42 PM, leonardo selmi wrote: i saved the above program from python shell into a file as circle.py . Which copied too much into the file. Edit circle.py until it is a proper python program. My initial guess was that you copied the prompts, but you later message shows that it was the welcome header. Header and prompts all need to go. Idle makes it easier to cut and paste a single statement from its shell to an editor window and then save. Or start your code in an editor, such as IDLE's. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Request META Help
On Thu, Apr 19, 2012 at 11:32 PM, Gabriel Novaes semprobl...@gmail.com wrote: The domains testes1.xyz.com.br, tes.xyzk.com.br, xx.xyzk.com.br through a DNS redirect TYPE A link to the server IP. In most cases I get the request.META ['HTTP_HOST'] with the URL in the request header, but today I had a problem that a customer made an appointment for me, and I get the IP of the server that information. Actually I need to get tes.xyzk.com.br Does anyone know better how it works? How can I overcome this? As I understand it, your customer accessed your web site via direct IP address. The easiest way to deal with that is to have a single default name, and if the Host: header (which is what comes through as HTTP_HOST) doesn't match any of the names you're expecting, you treat it as though it had been sent as your default. This is how Apache works when using name-based virtual hosting, and you seem to be doing pretty much the same thing, so following convention will keep things convenient. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for help with Image color space conversion
...where the image data is loaded into a numpy array (1600x1200x3)... One comment: that is a big array, too big for the cache memory. I know that in these cases it makes a difference how many times the slices of the array are loaded and unloaded from RAM onto cache. One issue is that a 2D array l[i,j] is actually a 1D array: either l[i,j]=l[i*N+j] or l[i,j]=l[j*N+i] I don't know which in python/numpy. In the first case, when you fix i and change j, you get consecutive positions in the underlying 1D array, and they all belong to the same slice, which is loaded onto cache very fast as a block. If you do the opposite, you are making jumps to distant positions in the array (not a slice), and performance suffers. In gimp, for example, the underlying array is split into 'tiles', which are 64x64 pixel regions that can be loaded/unloaded as a block. And that's about all I know on the issue. So it ma -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for help with Image color space conversion
Reimplement colorsys.rgb_to_hsv() such that it operates on arrays instead of scalars. Only minor modifications are necessary. -- Robert Kern Thanks! I'll try and see if a newcomer like me can get his head around the array-centric modifications to colorsys. -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for help with Image color space conversion
ttest wrote: Reimplement colorsys.rgb_to_hsv() such that it operates on arrays instead of scalars. Only minor modifications are necessary. -- Robert Kern Thanks! I'll try and see if a newcomer like me can get his head around the array-centric modifications to colorsys. If you hit any roadblocks, drop in on numpy-discussion, and we'll help you out. http://www.scipy.org/Mailing_Lists -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for help with Image color space conversion
ttest wrote: Hello, I'm working on an image processing project using the Python Imaging Library along with numpy. Right now, I'm trying to build a speedy script for converting whole images between the RGB and the HSV (a.k.a. HSB) color spaces. Unfortunately, the code I've made so far runs dreadfully slow with even moderate-sized images. I'm under the impression that the crux of the problem is the fact that PIL's point method operates on only one band at a time, and to do a proper color space conversion, you need information about all three bands in a particular problem. This has forced me to do an awkward work-around where the image data is loaded into a numpy array (1600x1200x3), and a dinky for-loop run runs through the array picking up RGB values, converting to HSV, and dumping the results back into another array. How can I make this more efficient? Reimplement colorsys.rgb_to_hsv() such that it operates on arrays instead of scalars. Only minor modifications are necessary. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for help on naming conventions
Steven D'Aprano wrote: Are there any useful naming conventions for modules, classes and functions? For instance, should I name functions as verbs and classes as nouns? eg class Transformer(): pass def transform(): do_stuff What about the module name? transformations.py or transform.py? You probably want to read the PEP 8, Style Guide for Python Code: http://www.python.org/peps/pep-0008.html What do people do with their own code? Do folks find that being consistent helps them remember what is what, or do you name objects whatever feels right at the time? Naming convention are mostly a matter of personal taste (unless you are working in a larger team, where there are some official conventions that must be followed). So I would say the 'feels right' is the most important factor. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for help on naming conventions
On Monday 13 June 2005 03:59 am, Steven D'Aprano wrote: Are there any useful naming conventions for modules, classes and functions? For instance, should I name functions as verbs and classes as nouns? Hmm. Okay, here's a few I use: Classes are generally: Capitalized or CapWords and I use nouns. Unless it's a mix-in in which case, I use adjectives. This mirrors usage in the Zope sources, BTW. Method names are either: funkyCaps (Zope uses this) or lower_case_with_underscores. I use verb names for methods and functions with very few exceptions. I use nouns or occasionally adjectives for attributes. Constants or enumeration values are ALLCAPS or ALL_CAPS, and usually I define them within a namespace with a descriptive, all lower case name (a trivial class). The enumeration is usually abbreviated, but would be an adjective, e.g.: color.RED I use *plural* names for lists and tuples, but singular names for mappings. This is so that I can use the singular in the loop: for book in books: pass But I use single character variables in list comprehensions (and generators, except I haven't used them yet): late_books = [b for b in books if b.duedate datetime.now()] I also use single-character names in highly mathematical code: def dot_product(a,b): return a.x*b.x + a.y*b.y + a.z*b.z But if a variable is going to be used more than about 20 lines away from where it is defined, I use a descriptive word instead. I like to use Capital or CapWords for modules, too, although I'm beginning to wonder about that practice. I really hate redundancy like this: Topic.create_topic() and usually prefer: Topic.create() which of course means, I have to qualify things a lot in my code. This has never been an issue, but if it did, I would just introduce an intermediary like this (_ for .): Topic_create = Topic.create After that, it's kind of case-by-case. Do read PEP 8, too, of course. -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for Help in OpenSourcing a Project
www.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list