Re: Need help to understand not the answer
On Saturday, July 29, 2017 at 2:16:36 PM UTC-5, new_to_c0ding wrote: > Hello all, I have been scratching my head since morning but > could not understand this quiz question. I would appreciate > if someone could help me understand what is it asking me to > do. I dont need the answer but just the right direction to > look at. Hello. First of all, as i look over this "script template" that your instructor has supposedly provided, i am disgusted by the abysmal formatting. I'm not sure if what you provided here is an exact replica, or something that you have modified, but in either case, a little bit of proper formatting can go a loong way towards readability. For instance, When writing in natural languages (such as English), we utilize common structural elements and rules so that our text will be presented in manner that is recognizable to most readers. A few of these "high level structural components" include _spaces_, _sentences_ and _paragraphs_. And when writing code, we also utilize a "common structure". And one of the most important components of this "common structure" is the use of vertical whitespace. By properly utilizing vertical whitespace, we can separate the "paragraphs" of our code (aka: classes and functions) so that reading the code will be more intuitive. Of course, Structuring code is far more complicated than simply creating "visual buffers zones" around classes and functions, and many hours have been spent debating what is proper, and what is not. But being that in the "realms of the OOP paradigm" classes and methods are the most fundamental elements, it should come as no surprise that mastering the formatting of these elements is a vital first lesson. Now, Even though there is something of an "ideological war" raging as to exactly how much vertical whitespace should be used, and _where_ it should be used, most programmers will agree that the following example is acceptable. A common style is to place *ONE* vertical whitespace between each method in a class,and two vertical whitespaces between the classes themselves. Observe the following... ## BEGIN: READABLE CODE EXAMPLE ## class Location(object): """DOCSTRING MISSING!!!""" def __init__(self, x, y): self.x = x self.y = y def move(self, deltaX, deltaY): return Location(self.x + deltaX, self.y + deltaY) def getX(self): return self.x def getY(self): return self.y def dist_from(self, other): xDist = self.x - other.x yDist = self.y - other.y return (xDist**2 + yDist**2)**0.5 def __eq__(self, other): return (self.x == other.x and self.y == other.y) def __str__(self): return '<' + str(self.x) + ',' + str(self.y) + '>' class Campus(object): """DOCSTRING MISSING!!!""" def __init__(self, center_loc): self.center_loc = center_loc def __str__(self): return str(self.center_loc) class MITCampus(Campus): """ A MITCampus is a Campus that contains tents """ def __init__(self, center_loc, tent_loc=Location(0,0)): """ Assumes center_loc and tent_loc are Location objects Initializes a new Campus centered at location center_loc with a tent at location tent_loc """ # Your code here def add_tent(self, new_tent_loc): """ Assumes new_tent_loc is a[n *INSTANCE* of] Location Adds new_tent_loc to the campus only if the tent is at least 0.5 distance away from all other tents already there. Campus is unchanged otherwise. Returns True if it could add the tent, False otherwise. """ # Your code here def remove_tent(self, tent_loc): """ Assumes tent_loc is a[n *INSTANCE* of] Location Removes tent_loc from the campus. Raises a ValueError if there is not a tent at tent_loc. Does not return anything """ # Your code here def get_tents(self): """ Returns a list of all tents on the campus. The list should contain the string representation of the Location of a tent. The list should be sorted by the x coordinate of the location. """ # Your code here ## END: READABLE CODE EXAMPLE ## But what is most important to remember here is _not_ so much the _number_ of spaces used, but that the number is greater than _zero_, and that the spacing is _consistent_. For instance: if one feels that two spaces between methods is more desirable then that is okay, but, one should maintain the two space buffer between *ALL* methods in the script *AND* furthermore, expand the b
Re: Need help to understand not the answer
On Saturday, July 29, 2017 at 3:49:55 PM UTC-4, MRAB wrote: > On 2017-07-29 20:16, new_to_c0ding wrote: > > Hello all, > > I have been scratching my head since morning but could not understand this > > quiz question. I would appreciate if someone could help me understand what > > is it asking me to do. I dont need the answer but just the right direction > > to look at. > > > > ### Do not change the Location or Campus classes. ### > > ### Location class is the same as in lecture. ### > > class Location(object): > > def __init__(self, x, y): > > self.x = x > > self.y = y > > def move(self, deltaX, deltaY): > > return Location(self.x + deltaX, self.y + deltaY) > > def getX(self): > > return self.x > > def getY(self): > > return self.y > > def dist_from(self, other): > > xDist = self.x - other.x > > yDist = self.y - other.y > > return (xDist**2 + yDist**2)**0.5 > > def __eq__(self, other): > > return (self.x == other.x and self.y == other.y) > > def __str__(self): > > return '<' + str(self.x) + ',' + str(self.y) + '>' > > > > class Campus(object): > > def __init__(self, center_loc): > > self.center_loc = center_loc > > def __str__(self): > > return str(self.center_loc) > > class MITCampus(Campus): > > """ A MITCampus is a Campus that contains tents """ > > def __init__(self, center_loc, tent_loc = Location(0,0)): > > """ Assumes center_loc and tent_loc are Location objects > > Initializes a new Campus centered at location center_loc > > with a tent at location tent_loc """ > > # Your code here > > > > def add_tent(self, new_tent_loc): > > """ Assumes new_tent_loc is a Location > > Adds new_tent_loc to the campus only if the tent is at least 0.5 > > distance > > away from all other tents already there. Campus is unchanged > > otherwise. > > Returns True if it could add the tent, False otherwise. """ > > # Your code here > > > > def remove_tent(self, tent_loc): > > """ Assumes tent_loc is a Location > > Removes tent_loc from the campus. > > Raises a ValueError if there is not a tent at tent_loc. > > Does not return anything """ > > # Your code here > > > > def get_tents(self): > > """ Returns a list of all tents on the campus. The list should > > contain > > the string representation of the Location of a tent. The list > > should > > be sorted by the x coordinate of the location. """ > > # Your code here > > > > > > > > -=-=-=-=-=-=-= > > > > For example, if c = MITCampus(Location(1,2)) then executing the following > > sequence of commands: > > > > c.add_tent(Location(2,3)) should return True > > c.add_tent(Location(1,2)) should return True > > c.add_tent(Location(0,0)) should return False > > c.add_tent(Location(2,3)) should return False > > c.get_tents() should return ['<0,0>', '<1,2>', '<2,3>'] > > > > -=-=-=-=-=-=- > > > > Now as per instructions, class MITCampus(Campus) has (self, center_loc, > > tent_loc = Location(0,0)) and it is mentioned that center_loc and tent_loc > > are Location objects but when I code them as Locations, I get error from > > the tester: > > Traceback (most recent call last): > >File "submission.py", line 61, in __init__ > > self.cloc=Location(center_loc) > > TypeError: __init__() missing 1 required positional argument: 'y' > > > > -=-=-=-== > > > > Please help > > > Location.__init__ expects 3 arguments: self, x, y > > self is already provided, so that leaves 2 arguments: x, y > > You're giving it only 1 argument: center_loc > > What is center_loc? Is it a tuple? > > If it is, then you could do: > > self.cloc=Location(center_loc[0], center_loc[1]) > > or: > > self.cloc=Location(*center_loc) Hi, thanks for replying. As per the description it is a Location object. And that result is from the tester so it should have provided two values if it was expecting it to be a location object. -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help to understand not the answer
On 2017-07-29 20:16, new_to_c0ding wrote: Hello all, I have been scratching my head since morning but could not understand this quiz question. I would appreciate if someone could help me understand what is it asking me to do. I dont need the answer but just the right direction to look at. ### Do not change the Location or Campus classes. ### ### Location class is the same as in lecture. ### class Location(object): def __init__(self, x, y): self.x = x self.y = y def move(self, deltaX, deltaY): return Location(self.x + deltaX, self.y + deltaY) def getX(self): return self.x def getY(self): return self.y def dist_from(self, other): xDist = self.x - other.x yDist = self.y - other.y return (xDist**2 + yDist**2)**0.5 def __eq__(self, other): return (self.x == other.x and self.y == other.y) def __str__(self): return '<' + str(self.x) + ',' + str(self.y) + '>' class Campus(object): def __init__(self, center_loc): self.center_loc = center_loc def __str__(self): return str(self.center_loc) class MITCampus(Campus): """ A MITCampus is a Campus that contains tents """ def __init__(self, center_loc, tent_loc = Location(0,0)): """ Assumes center_loc and tent_loc are Location objects Initializes a new Campus centered at location center_loc with a tent at location tent_loc """ # Your code here def add_tent(self, new_tent_loc): """ Assumes new_tent_loc is a Location Adds new_tent_loc to the campus only if the tent is at least 0.5 distance away from all other tents already there. Campus is unchanged otherwise. Returns True if it could add the tent, False otherwise. """ # Your code here def remove_tent(self, tent_loc): """ Assumes tent_loc is a Location Removes tent_loc from the campus. Raises a ValueError if there is not a tent at tent_loc. Does not return anything """ # Your code here def get_tents(self): """ Returns a list of all tents on the campus. The list should contain the string representation of the Location of a tent. The list should be sorted by the x coordinate of the location. """ # Your code here -=-=-=-=-=-=-= For example, if c = MITCampus(Location(1,2)) then executing the following sequence of commands: c.add_tent(Location(2,3)) should return True c.add_tent(Location(1,2)) should return True c.add_tent(Location(0,0)) should return False c.add_tent(Location(2,3)) should return False c.get_tents() should return ['<0,0>', '<1,2>', '<2,3>'] -=-=-=-=-=-=- Now as per instructions, class MITCampus(Campus) has (self, center_loc, tent_loc = Location(0,0)) and it is mentioned that center_loc and tent_loc are Location objects but when I code them as Locations, I get error from the tester: Traceback (most recent call last): File "submission.py", line 61, in __init__ self.cloc=Location(center_loc) TypeError: __init__() missing 1 required positional argument: 'y' -=-=-=-== Please help Location.__init__ expects 3 arguments: self, x, y self is already provided, so that leaves 2 arguments: x, y You're giving it only 1 argument: center_loc What is center_loc? Is it a tuple? If it is, then you could do: self.cloc=Location(center_loc[0], center_loc[1]) or: self.cloc=Location(*center_loc) -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help to understand not the answer
new_to_c0ding writes: > Now as per instructions, class MITCampus(Campus) has (self, center_loc, > tent_loc = Location(0,0)) and it is mentioned that center_loc and tent_loc > are Location objects but when I code them as Locations, I get error from the > tester: > Traceback (most recent call last): > File "submission.py", line 61, in __init__ > self.cloc=Location(center_loc) > TypeError: __init__() missing 1 required positional argument: 'y' Location must be called with 2 parameters: a x and a y coordinate, not with another location as parameter. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Need help to understand not the answer
Hello all, I have been scratching my head since morning but could not understand this quiz question. I would appreciate if someone could help me understand what is it asking me to do. I dont need the answer but just the right direction to look at. ### Do not change the Location or Campus classes. ### ### Location class is the same as in lecture. ### class Location(object): def __init__(self, x, y): self.x = x self.y = y def move(self, deltaX, deltaY): return Location(self.x + deltaX, self.y + deltaY) def getX(self): return self.x def getY(self): return self.y def dist_from(self, other): xDist = self.x - other.x yDist = self.y - other.y return (xDist**2 + yDist**2)**0.5 def __eq__(self, other): return (self.x == other.x and self.y == other.y) def __str__(self): return '<' + str(self.x) + ',' + str(self.y) + '>' class Campus(object): def __init__(self, center_loc): self.center_loc = center_loc def __str__(self): return str(self.center_loc) class MITCampus(Campus): """ A MITCampus is a Campus that contains tents """ def __init__(self, center_loc, tent_loc = Location(0,0)): """ Assumes center_loc and tent_loc are Location objects Initializes a new Campus centered at location center_loc with a tent at location tent_loc """ # Your code here def add_tent(self, new_tent_loc): """ Assumes new_tent_loc is a Location Adds new_tent_loc to the campus only if the tent is at least 0.5 distance away from all other tents already there. Campus is unchanged otherwise. Returns True if it could add the tent, False otherwise. """ # Your code here def remove_tent(self, tent_loc): """ Assumes tent_loc is a Location Removes tent_loc from the campus. Raises a ValueError if there is not a tent at tent_loc. Does not return anything """ # Your code here def get_tents(self): """ Returns a list of all tents on the campus. The list should contain the string representation of the Location of a tent. The list should be sorted by the x coordinate of the location. """ # Your code here -=-=-=-=-=-=-= For example, if c = MITCampus(Location(1,2)) then executing the following sequence of commands: c.add_tent(Location(2,3)) should return True c.add_tent(Location(1,2)) should return True c.add_tent(Location(0,0)) should return False c.add_tent(Location(2,3)) should return False c.get_tents() should return ['<0,0>', '<1,2>', '<2,3>'] -=-=-=-=-=-=- Now as per instructions, class MITCampus(Campus) has (self, center_loc, tent_loc = Location(0,0)) and it is mentioned that center_loc and tent_loc are Location objects but when I code them as Locations, I get error from the tester: Traceback (most recent call last): File "submission.py", line 61, in __init__ self.cloc=Location(center_loc) TypeError: __init__() missing 1 required positional argument: 'y' -=-=-=-== Please help -- https://mail.python.org/mailman/listinfo/python-list
Re: Program prints questions for user input, but won't show the answer output
On 05/18/2016 06:50 PM, Jake Kobs wrote: MRAB, I am not quite sure how to return the print statements so I thought that returning the displayInfo def would help.. Im so lost. Why do you think you want to _return_ a print statement? The print statement _DOES_ the printing, there is nothing that needs to be returned. Sometimes you might want to return a _string_ to be printed where it was called from, but that's not what you want here. You say that the display info isn't shown... It looks to me like it it isn't shown because your program will crash. What you have here is called "infinite recursion": displayInfo() calls displayInfo() which calls displayInfo() which calls displayInfo() which calls ... and so on forever. Another comment: Your getHigh() and getLow() functions are not necessary. Python already has max() and min() functions built in to do this exact same thing. Instead you can use: highPints = max(pints) lowPints = min(pints) Of course, writing your own versions as a leaning experience is good too. But I would suggest that a for loop instead of a while in your version would be better. For one thing, it eliminates the counter. My suggested version... def getHigh(pints): high = 0 for pint in pints: if pint > high: high = pint return high And getLow() is similar (but set the initial value to a high number). The following example may be more advanced than you're ready for now, but you _might_ find it worth studying. It's possible to do both in a single function: def getMaxMin(pints): high = low = pints[0]# Initialize high and low to the first value of the array for pint in pints[1:]: # Scan through the remainder of the pints array if pint > high: high = pint if pint < low: low = pint return high, low You would use it as: highPints, lowPints = getMaxMin(pints) I'm NOT necessarily recommending this, but just suggesting it as an example to study. Good luck with your Python studies. It's a great language to learn. -=- Larry -=- PS. A final thought... I don't know your situation so this may not be reasonable but... I HIGHLY recommend switching to Python 3 instead of 2. Version 2 is at "end-of-life" and won't be updated any further. Version 3 is where all future development will occur. It is definitely the better version, and while there are certainly differences, to a beginning programmer the learning curve will be the same. -- https://mail.python.org/mailman/listinfo/python-list
Re: Program prints questions for user input, but won't show the answer output
On 2016-05-19 02:50, Jake Kobs wrote: MRAB, I am not quite sure how to return the print statements so I thought that returning the displayInfo def would help.. Im so lost. "return the print statements"? The print statements ... print! Have a search for Python tutorials online and pick one that suits you. I see that you're using Python 2. I'd suggest trying Python 3 unless you have a good reason for using Python 2. -- https://mail.python.org/mailman/listinfo/python-list
Re: Program prints questions for user input, but won't show the answer output
On Thu, 19 May 2016 11:50 am, Jake Kobs wrote: > MRAB, > > I am not quite sure how to return the print statements so I thought that > returning the displayInfo def would help.. Im so lost. There's no need to return the text that you printed. You printed it, the job is done. Here is some general advice that may help you be less lost. (1) Each function should do "one thing". For example, it either collects information, or it displays it. It shouldn't do both. Your code seems pretty good at following that guideline already, well done. (2) Use existing functions as much as possible. The Python docs has a list of the built-in functions here: https://docs.python.org/2/library/functions.html Refer to that as often as possible. For example, your functions getHigh, getLow and getTotal functions just re-invent the wheel. Python already has functions to do that: max, min, sum In Python 2, there's no built-in function for average, but for your purposes you can just use sum(pints)/len(pints). (3) Whoever taught you to write while loops should be taken out and horse-whipped. While loops are for looping when you don't know in advance how many times you need to repeat. When you do know how many times to repeat, use a for-loop: # I want to repeat seven times for counter in range(7): print "Loop", counter Isn't that simpler than a while loop? # I want to repeat seven times counter = 7 while counter > 0: # or should that be >= 0? >= 1? I forget! print "Loop", counter counter -= 1 And its faster too. (4) Don't use "input". (The reasons are technical, if you really want to know, please ask.) Instead of writing: input("Enter pints collected: ") write this: int(raw_input("Enter pints collected: ")) -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Program prints questions for user input, but won't show the answer output
MRAB, I am not quite sure how to return the print statements so I thought that returning the displayInfo def would help.. Im so lost. -- https://mail.python.org/mailman/listinfo/python-list
Re: Program prints questions for user input, but won't show the answer output
On 2016-05-19 02:04, Jake Kobs wrote: Here is the code: #Lab 9-4 Blood Drive #the main function def main(): endProgram = 'no' while endProgram == 'no': print # declare variables pints = [0] * 7 totalPints = 0 averagePints = 0 highPints = 0 lowPints = 0 # function calls pints = getPints(pints) totalPints = getTotal(pints, totalPints) averagePints = getAverage(totalPints, averagePints) highPints = getHigh(pints, highPints) lowPints = getLow(pints, lowPints) displayInfo(averagePints, highPints, lowPints) endProgram = raw_input('Do you want to end program? (Enter no or yes): ') while not (endProgram == 'yes' or endProgram == 'no'): print 'Please enter a yes or no' endProgram = raw_input('Do you want to end program? (Enter no or yes): ') #the getPints function def getPints(pints): counter = 0 while counter < 7: pints[counter] = input("Enter pints collected: ") counter = counter + 1 return pints #the getTotal function def getTotal(pints, totalPints): counter = 0 while counter < 7: totalPints = totalPints + pints[counter] counter = counter + 1 return totalPints #the getAverage function def getAverage(totalPints, averagePints): averagePints = totalPints / 7 return averagePints #the getHigh function def getHigh(pints, highPints): highPints = pints[0] counter = 1 while counter < 7: if (pints[counter] > highPints): highPints = pints[counter] The indentation here is wrong: counter = counter + 1 It will add 1 _only_ if pints[counter] > highPints. return highPints #the getLow function def getLow(pints, lowPints): lowPints = pints[0] counter = 1 while counter < 7: if (pints[counter] < lowPints): lowPints = pints[counter] The indentation here is wrong: counter = counter + 1 It will add 1 _only_ if pints[counter] < highPints. return lowPints #the displayInfo function def displayInfo(averagePints, highPints, lowPints): print "The average pints donated was: ", averagePints print "The highest amount of pints donated was: ", highPints print "The lowest amount of pints donated was: ", lowPints Why is 'displayInfo' calling itself here? return displayInfo(averagePints, highPints, lowPints) main() The problem is that the display info isn't shown after the user types in their 7 numerical values. Please help. -- https://mail.python.org/mailman/listinfo/python-list
Re: Program prints questions for user input, but won't show the answer output
In <1cc14787-7061-45c9-a70e-1b16e3f5e...@googlegroups.com> Jake Kobs writes: > Here is the code: > def getHigh(pints, highPints): > highPints = pints[0] > counter = 1 > while counter < 7: > if (pints[counter] > highPints): > highPints = pints[counter] > counter = counter + 1 > return highPints getHigh() goes into an infinite loop if pints[counter] is less than or equal to highPints. > def getLow(pints, lowPints): > lowPints = pints[0] > counter = 1 > while counter < 7: > if (pints[counter] < lowPints): > lowPints = pints[counter] > counter = counter + 1 > return lowPints And getLow() has a very similar problem. I suspect you want to unindent the 'counter = counter + 1' statement so that it is NOT inside the 'if' statement. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list
Program prints questions for user input, but won't show the answer output
Here is the code: #Lab 9-4 Blood Drive #the main function def main(): endProgram = 'no' while endProgram == 'no': print # declare variables pints = [0] * 7 totalPints = 0 averagePints = 0 highPints = 0 lowPints = 0 # function calls pints = getPints(pints) totalPints = getTotal(pints, totalPints) averagePints = getAverage(totalPints, averagePints) highPints = getHigh(pints, highPints) lowPints = getLow(pints, lowPints) displayInfo(averagePints, highPints, lowPints) endProgram = raw_input('Do you want to end program? (Enter no or yes): ') while not (endProgram == 'yes' or endProgram == 'no'): print 'Please enter a yes or no' endProgram = raw_input('Do you want to end program? (Enter no or yes): ') #the getPints function def getPints(pints): counter = 0 while counter < 7: pints[counter] = input("Enter pints collected: ") counter = counter + 1 return pints #the getTotal function def getTotal(pints, totalPints): counter = 0 while counter < 7: totalPints = totalPints + pints[counter] counter = counter + 1 return totalPints #the getAverage function def getAverage(totalPints, averagePints): averagePints = totalPints / 7 return averagePints #the getHigh function def getHigh(pints, highPints): highPints = pints[0] counter = 1 while counter < 7: if (pints[counter] > highPints): highPints = pints[counter] counter = counter + 1 return highPints #the getLow function def getLow(pints, lowPints): lowPints = pints[0] counter = 1 while counter < 7: if (pints[counter] < lowPints): lowPints = pints[counter] counter = counter + 1 return lowPints #the displayInfo function def displayInfo(averagePints, highPints, lowPints): print "The average pints donated was: ", averagePints print "The highest amount of pints donated was: ", highPints print "The lowest amount of pints donated was: ", lowPints return displayInfo(averagePints, highPints, lowPints) main() The problem is that the display info isn't shown after the user types in their 7 numerical values. Please help. -- https://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Is context manager the answer to synchronous function calls?
Ah. Thanks.. I removed the previous code. Please excuse me. I will rewrite the question so it is clear. Here is my current solution in an imperative way. My application will work with AWS boto library to create EC2 instances and RDS instances. Assuming my API will simply send the request, and return if the request is accepted, I need to lock until the instance is ready before I can start the next operation. def create_vm(.): # returns vm object def modify_vm(.): return new vm object def get_vm_status(.): return status # NOTE: This is obviously a simplified version, but pretty much half of the code. def lock_until_ready(conn, get_status_func, _id, max_wait=60): wait_count = 1 status = get_status_func(conn, _id) while status != 'available' and wait_count < max_wait: print("Querying status (attempt {i}): {status}".format( i=wait_count, status=status)) wait_count += 1 time.sleep(10) status = get_status_func(conn, _id) def clone(data_center, image_id, options): conn = get_connection(data_center) vm_id = create_vm(conn, image_id, ) lock_until_ready(conn, get_vm_status, vm_id, max_wait=30) modify_vm(conn, options) lock_until_ready(conn, get_vm_status, vm_id, max_wait=30) I hope this doesn't come across as a code review. This works. I made my lock function extensible and testable, but I feel like there should be a better more user-friendly way, even in the imperative world in Python. I thought of context manager because I can do some clean up on entry (verify the db name has not been taken), and exit (if fail rollback). If you are familiar with cloudformation, it almost seems like that's what I am doing. I am writing this because I have custom needs that cloudformation can't do elegantly without many hops. API is much more flexible for my current task, FYI. Any feedback is welcome. Thank you. John On Wed, Sep 16, 2015 at 10:53 AM, Chris Angelico wrote: > On Thu, Sep 17, 2015 at 12:34 AM, John Wong wrote: > > Sorry first time posting to tutor / general list. Usually on TIP list. As > > per Mark's recommendation, now posting to python-list@python.org. > > But, sadly, without a lot of context. When you change lists, it's > helpful to include a lot of extra verbiage so folks who don't follow > the other list can pick up where you were. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Is context manager the answer to synchronous function calls?
On Thu, Sep 17, 2015 at 12:34 AM, John Wong wrote: > Sorry first time posting to tutor / general list. Usually on TIP list. As > per Mark's recommendation, now posting to python-list@python.org. But, sadly, without a lot of context. When you change lists, it's helpful to include a lot of extra verbiage so folks who don't follow the other list can pick up where you were. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Is context manager the answer to synchronous function calls?
On Wed, Sep 16, 2015 at 7:54 AM, Mark Lawrence wrote: > > Assuming your (Alan's) guess is correct, and I certainly agree it's > plausible, I suspect this might be better asked on the main Python mailing > list, I don't see this as tutor material. > > Sorry first time posting to tutor / general list. Usually on TIP list. As per Mark's recommendation, now posting to python-list@python.org. On Wed, Sep 16, 2015 at 6:56 AM, Alan Gauld wrote: > > You don't actually specify but I'm guessing VM > means Virtual Machine? Is it a specific type > of VM? eg VMWare/VirtualBox or somesuch, or is > it more of a sandbox environment like virtualenv? > That might help us understand the restrictions better. In my case my underlying functions will use boto (Amazon Web Service's Python SDK) but I thought to abstract the details away from posting because as you know I want to simply return an object. But yes, boto will simply return the call with a response object. For example, to create an RDS database, the call is returned and I will to query for the status of the database before I can perform further actions to the instance such as changing password (which is covered in the modify_vm function call). But creating VM such as EC2 has an equal synchronous nature. I would be tempted to use an asynchronous approach with a > when_ready() function that takes my function as an input > parameter. You could then run the when_ready in a thread > or, I suspect, utilize the asyncio or asyncore modules, > although I haven't tried using them for this kind of > thing myself. > The bottom line is you need to wait for the status to > change. How you do that wait is up to you but you can > make it more readable for the user. The easier it is for > the user the harder it will be for you. > > Sounds like to make it readable and user friendly, also to have separation of concern, I almost am locked into implementing in OOP style. Imperative seems to be okay but lack the "shininess." Thank you. John -- https://mail.python.org/mailman/listinfo/python-list
Re: I'm a newbie and you helped me find the answer...
Thank you, Jussi. Problem finally solved. I am using Coderunner 2 as my editor. It has a language setting. I had set it as Python instead of Python 3. Duh! Thank you again, everyone! With appreciation, Dwight dwi...@goldwinde.com www.goldwinde.com Author of the book, "Courage: the Choice that Makes the Difference--Your Key to a Thousand Doors" You can find all my books at http://www.couragebooks.key.to/ 1-206-923-9554 (USA Telephone) 1-206-350-0129 (voice mail and fax U.S.A.) 86-153-9867-5712 (China Telephone) goldwindedwight (Skype) goldwinde (Wechat) +8615398675712 (Whatsapp) www.3forliving.key.to (daily living video playlist) http://www.couragebooks.key.to/ (my books) On 8/3/15, 5:49 PM, "Jussi Piitulainen" wrote: >Dwight GoldWinde quotes himself: >> >>> Okay, thank you, Dave, so I got the following info: type $(which >>> python3) >>> /Library/Frameworks/Python.framework/Versions/3.4/bin/python3 is >>> /Library/Frameworks/Python.framework/Versions/3.4/bin/python3 >>> >>> But I can¹t figure out what short of ³usr² statement >>> (e.g. #!/usr/bin/env python3) I need to point it there. Whatever I >>> tried, still gives me version 2. > >How are you launching your script? If your method involves clicking some >pretty picture or something similar, you may be bypassing /usr/bin/env >altogether and relying on some association of file types in Mac OS. Then >you need to investigate file properties in Finder, or something like >that. It should be safe to change the association for that individual >script but not necessarily for all files with the same extension. > >If your method is to type "python scriptname" at the shell prompt, you >are definitely bypassing /usr/bin/env and specifying the default python >as the one to use. Solution: type "python3 scriptname" instead. (A more >advanced solution: make scriptname executable and type "./scriptname" >instead. This one uses /usr/bin/env to find the interpreter.) > >(You could try "#!/usr/bin/env aintgotnosuch" as your script's hashbang >line to see if it even matters what that line says. Check first that you >don't happen to have a program named "aintgotnosuch" in your path.) >-- >https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
the ressurection of ZOPE for web domination? bluebream and caveman the answer?
i loved the rant about how zope would have all these features, and then some other python framework would come on with like 1 and act like its the bomb, and zope was like we been doing that and more for X years those who dont study zope are doomed to repeat it!!! is zope scoffing at drupal? botle? pyramid ? -- https://mail.python.org/mailman/listinfo/python-list
Re: The answer
On Jan 17, 8:30 pm, Jive Dadson wrote: > Okay, with your help I've figured it out. Instructions are below, but > read the caveat by Ben Fenny in this thread. All this stuff is good for > one default version of Python only. The PYTHONPATH described below, for > example, cannot specify a version number. Yes, that's a pain in the > butt, but there's no way around it. If you switch versions, you may > have to delete all the .pyc files that will show up in the module > folders. Python ought to check them to see if they are valid, but I do > not know if it does so. > > These instructions are for MS Windows. > > 1) Create your modules folder. Let's say it's named "Modules." The > documentation calls it a "package." > > 2) In an explorer window or on the desktop, right click on My Computer, > and select Properties. > > 3) Select the Advanced tab, and click on Environment Variables near the > bottom. > > 4) Look for an environment variable named PYTHONPATH. > > a) If you do not find one, create one using the New button(s). I > don't know if it has to be in User Variables or System Variables. To > save time experimenting, I just put one in both. For the value, put the > full path of the folder Modules. > > b) If there's already a PYTHONPATH, Edit it, adding a semi-colon > and the full path of folder Module to the end. > > 5) Put your module folders into the folder Module. > > 6) (Here's a really arcane bit.) Into each module folder, put a file > named __init__.py. It will be executed when you load the module. It > can be empty, but it has to be there or else the module folder will be > ignored. In your original thread, you never quite said why you can't use site- packages and .pth files. Are you not allowed to modify your local installation? If you are writing something for distribution to others, then site-packages and .pth files are the best way to go, since they don't assume any particular operating system. If you can't (or won't) use them, then just create Module as a sub-directory of wherever your program lives, since that directory is always prepended to PYTHONPATH. If you need to use the same module from multiple directories, most modern operating systems support symbolic links; if you're using Windows, well, here's a nickel kid, get yourself a better computer (http://farm1.static.flickr.com/ 89/240711122_f9888e5a3b_o.jpg). I don't think that __init__.py is very arcane, since it is described in detail in the documentation. It's also a great place to use the standard site.addsitedir() function, which is another platform independent way to manipulate Python's search path. -- http://mail.python.org/mailman/listinfo/python-list
Re: The answer
Jive Dadson wrote: alex23 wrote: > > Actually, if you're using Python 2.6+/3.x, you can effectively skip > steps 1-5, as these versions now support user site-packages. > > Rather than create a Module folder and modify your PYTHONPATH, add (if > it doesn't exist already) the following folder: > %APPDATA%/Python/Python26/site-packages > > Modules can sit directly in the folder, or within packages. > > For more details: http://www.python.org/dev/peps/pep-0370/ That requires a directory whose name embeds the Python version number, which is the evil from which I flee, or rather sought to flee. Imagine if all your C++ code had to go into directories that were named for some specific C++ compiler. It's just WRONG. It's a maintenance nightmare to have a bunch of different source files that all have to be updated whenever you fix a bug or add a feature. As others have pointed out, you need a "deploy" script, which in your case would copy the files from source control to the appropriate production folder. That's analogous to the compile, link and deploy steps of C++. And if you want to be even more analogous, copy just the .pyc files, after building them. Certainly you have lots more files in your version control system which are not intended to be copied to the "Modules" folder, such as the test suite. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: The answer
On 01/18/10 13:30, Jive Dadson wrote: > Okay, with your help I've figured it out. Instructions are below, but > read the caveat by Ben Fenny in this thread. All this stuff is good for > one default version of Python only. The PYTHONPATH described below, for > example, cannot specify a version number. Yes, that's a pain in the > butt, but there's no way around it. If you switch versions, you may > have to delete all the .pyc files that will show up in the module > folders. Python ought to check them to see if they are valid, but I do > not know if it does so. Err... "The answer" to... what? -- http://mail.python.org/mailman/listinfo/python-list
Re: The answer
Jive Dadson wrote: > That requires a directory whose name embeds the Python version number, > which is the evil from which I flee, or rather sought to flee. Imagine > if all your C++ code had to go into directories that were named for some > specific C++ compiler. It's just WRONG. It's a maintenance nightmare > to have a bunch of different source files that all have to be updated > whenever you fix a bug or add a feature. With the PEP 370 approach, you can just designate a folder the core one and symlink all other versions to it. Or better yet, use version control to push updates to each folder. With all of the versions sharing one folder, as you'd prefer, it would be a lot more difficult to actually achieve version-level granularity if and when you need it. It's not WRONG, it's just providing a level of control that you don't need at this point. -- http://mail.python.org/mailman/listinfo/python-list
Re: The answer
alex23 wrote: > > Actually, if you're using Python 2.6+/3.x, you can effectively skip > steps 1-5, as these versions now support user site-packages. > > Rather than create a Module folder and modify your PYTHONPATH, add (if > it doesn't exist already) the following folder: > %APPDATA%/Python/Python26/site-packages > > Modules can sit directly in the folder, or within packages. > > For more details: http://www.python.org/dev/peps/pep-0370/ That requires a directory whose name embeds the Python version number, which is the evil from which I flee, or rather sought to flee. Imagine if all your C++ code had to go into directories that were named for some specific C++ compiler. It's just WRONG. It's a maintenance nightmare to have a bunch of different source files that all have to be updated whenever you fix a bug or add a feature. -- http://mail.python.org/mailman/listinfo/python-list
Re: The answer
On Jan 18, 12:30 pm, Jive Dadson wrote: > These instructions are for MS Windows. > > 1) Create your modules folder. Let's say it's named "Modules." The > documentation calls it a "package." > > 2) In an explorer window or on the desktop, right click on My Computer, > and select Properties. > > 3) Select the Advanced tab, and click on Environment Variables near the > bottom. > > 4) Look for an environment variable named PYTHONPATH. > > a) If you do not find one, create one using the New button(s). I > don't know if it has to be in User Variables or System Variables. To > save time experimenting, I just put one in both. For the value, put the > full path of the folder Modules. > > b) If there's already a PYTHONPATH, Edit it, adding a semi-colon > and the full path of folder Module to the end. > > 5) Put your module folders into the folder Module. > > 6) (Here's a really arcane bit.) Into each module folder, put a file > named __init__.py. It will be executed when you load the module. It > can be empty, but it has to be there or else the module folder will be > ignored. Actually, if you're using Python 2.6+/3.x, you can effectively skip steps 1-5, as these versions now support user site-packages. Rather than create a Module folder and modify your PYTHONPATH, add (if it doesn't exist already) the following folder: %APPDATA%/Python/Python26/site-packages Modules can sit directly in the folder, or within packages. For more details: http://www.python.org/dev/peps/pep-0370/ -- http://mail.python.org/mailman/listinfo/python-list
Re: The answer
* Jive Dadson: Okay, with your help I've figured it out. Instructions are below, but read the caveat by Ben Fenny in this thread. All this stuff is good for one default version of Python only. The PYTHONPATH described below, for example, cannot specify a version number. Yes, that's a pain in the butt, but there's no way around it. If you switch versions, you may have to delete all the .pyc files that will show up in the module folders. Python ought to check them to see if they are valid, but I do not know if it does so. These instructions are for MS Windows. 1) Create your modules folder. Let's say it's named "Modules." The documentation calls it a "package." 2) In an explorer window or on the desktop, right click on My Computer, and select Properties. 3) Select the Advanced tab, and click on Environment Variables near the bottom. 4) Look for an environment variable named PYTHONPATH. a) If you do not find one, create one using the New button(s). I don't know if it has to be in User Variables or System Variables. To save time experimenting, I just put one in both. For the value, put the full path of the folder Modules. The User variables /override/ the System variables for a given user. The System variables provide defaults for all users. One notable exception is PATH, where the User PATH items are appended to the System PATH. Anyways, with many items in a variable like PATH it can be impractical to use Windows' functionality, which presents it all on one line, which for a PATH with many items can be exceeding long -- like a many thousand characters[1] line. So for your convenience, below is a little Windows app (as an HTML application, it's just some HTML and VBScript and CSS) that presents the user PATH items one per line in a Notepad-like window. It should be no problem modifying it to instead edit PYTHONPATH, or even a choice of environment variable. As my late father used to say, when you don't have a tool, you make it. Maybe now I should recode this in Python. But on the other hand, one shouldn't spend time fixing what works. So ... enjoy! :-) Note: it's crucial to use [.HTA] filename extension. Also, it's quite possible that this doesn't work in Windows Vista (at least not without configuration of Windows), but it works in XP and earlier. content="http://schemas.microsoft.com/intellisense/ie5";> Simple user-environment %path% editor body{ margin: 0px; padding: 0px; } #menuArea { width: 100%; height: 1.8em; white-space: nowrap; padding-top: 2px; background: #E0E0E0; } #clientArea { width: 100%; position: absolute; top: 1.8em; bottom: 0; } #pathEditor { display: inline-block; width: 100%; height: 100%; border: 0; position: absolute; top: 0; overflow: scroll; } option explicit dim wshShell dim wshUserEnv dim originalText sub loadTextpathEditor.innerText = replace( wshUserEnv( "PATH" ), ";", vbNewline)end sub sub saveText dim text dim button text = pathEditor.innerText text = replace( text, vbNewLine, ";" ) button = MsgBox( _ text, vbYesNo + vbQuestion, "Save this as new %path% value?" _ ) if button = vbYes then wshUserEnv( "PATH" ) = text end sub sub onBtnLoad loadText end sub sub onBtnLoadOriginal pathEditor.innerText = originalText end sub sub onBtnSave saveText end sub sub onLoaded set wshShell = createObject( "WScript.Shell" ) set wshUserEnv = wshShell.environment( "USER" ) loadText originalText = pathEditor.innerText MsgBox _ "Type one path per line (no semicolons)", _ vbInformation, _ "How to use:" end sub Load current Reload original Save as current ... b) If there's already a PYTHONPATH, Edit it, adding a semi-colon and the full path of folder Module to the end. 5) Put your module folders into the folder Module. 6) (Here's a really arcane bit.) Into each module folder, put a file named __init__.py. It will be executed when you load the module. It can be empty, but it has t
The answer
Okay, with your help I've figured it out. Instructions are below, but read the caveat by Ben Fenny in this thread. All this stuff is good for one default version of Python only. The PYTHONPATH described below, for example, cannot specify a version number. Yes, that's a pain in the butt, but there's no way around it. If you switch versions, you may have to delete all the .pyc files that will show up in the module folders. Python ought to check them to see if they are valid, but I do not know if it does so. These instructions are for MS Windows. 1) Create your modules folder. Let's say it's named "Modules." The documentation calls it a "package." 2) In an explorer window or on the desktop, right click on My Computer, and select Properties. 3) Select the Advanced tab, and click on Environment Variables near the bottom. 4) Look for an environment variable named PYTHONPATH. a) If you do not find one, create one using the New button(s). I don't know if it has to be in User Variables or System Variables. To save time experimenting, I just put one in both. For the value, put the full path of the folder Modules. b) If there's already a PYTHONPATH, Edit it, adding a semi-colon and the full path of folder Module to the end. 5) Put your module folders into the folder Module. 6) (Here's a really arcane bit.) Into each module folder, put a file named __init__.py. It will be executed when you load the module. It can be empty, but it has to be there or else the module folder will be ignored. -- http://mail.python.org/mailman/listinfo/python-list
The answer
Okay, with your help I've figured it out. Instructions are below, but read the caveat by Ben Fenny in this thread. All this stuff is good for one default version of Python only. The PYTHONPATH described below, for example, cannot specify a version number. Yes, that's a pain in the butt, but there's no way around it. If you switch versions, you may have to delete all the .pyc files that will show up in the module folders. Python ought to check them to see if they are valid, but I do not know if it does so. These instructions are for MS Windows. 1) Create your modules folder. Let's say it's named "Modules." The documentation calls it a "package." 2) In an explorer window or on the desktop, right click on My Computer, and select Properties. 3) Select the Advanced tab, and click on Environment Variables near the bottom. 4) Look for an environment variable named PYTHONPATH. a) If you do not find one, create one using the New button(s). I don't know if it has to be in User Variables or System Variables. To save time experimenting, I just put one in both. For the value, put the full path of the folder Modules. b) If there's already a PYTHONPATH, Edit it, adding a semi-colon and the full path of folder Module to the end. 5) Put your module folders into the folder Module. 6) (Here's a really arcane bit.) Into each module folder, put a file named __init__.py. It will be executed when you load the module. It can be empty, but it has to be there or else the module folder will be ignored. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Ray wrote: > Does the comparison between dynamic and static language carry over to > comparison between Django and Turbogear too? Is this what is meant by > "Turbogear is much more flexible than Django"? Nah, the difference is more than Django is a complete product whereas TurboGears is a collection of unrelated parts glued together. For more on this topic, see here: http://www.oreillynet.com/pub/wlg/8986 Adrian -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Fredrik Lundh wrote: > I hope you're aware that this sounds a lot like late 90's anti-dynamic- > language propaganda... > > "I would never use Perl or Python over C++ for any performance- > "intensive Web app. In my opinion, both languages make some > poor design decisions regarding the importance of performance." > > (you all know all the counter-arguments) Does the comparison between dynamic and static language carry over to comparison between Django and Turbogear too? Is this what is meant by "Turbogear is much more flexible than Django"? Thanks, Ray > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Adrian Holovaty wrote: > I would never use TurboGears or Ruby on Rails over Django for any > performance-intensive Web app. In my opinion, both frameworks make some > poor design decisions regarding the importance of performance. I hope you're aware that this sounds a lot like late 90's anti-dynamic- language propaganda... "I would never use Perl or Python over C++ for any performance- "intensive Web app. In my opinion, both languages make some poor design decisions regarding the importance of performance." (you all know all the counter-arguments) -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
bruno at modulix wrote: > Possibly - but if a programmer is not able to pick on Python in a matter > of days, then it's a bad programmer that won't be of any help whatever > the language. So in fact, choosing Python may help you get better > programmers !-) You have a point there! :) > You may also want to have a look at turbogears (roughly similar to > Django, but probably much more flexible) Hmm--much more flexible in what sense, Bruno? Thanks much! Ray > > My 2 cents > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Very useful input, Adrian. Thanks a lot! These are facts that I can use to convince people that Python is a legit choice for the app I'm developing. Warm regards, Ray Adrian Holovaty wrote: > Ray wrote: > > Yes, but this is more of a web application though--something that I've > > never developed in Python before, so... I'll be evaluating Django > > shortly--let me see how it compares to Tomcat. > > Performance is one of the key features of Django. For example, I'm > using Django at washingtonpost.com for the U.S. Congress Votes > Database, which has more than 4 million records and is linked-to from > the washingtonpost.com home page whenever there's a key congressional > vote. (http://projects.washingtonpost.com/congress/) > > The server doesn't break a sweat, thanks to Django's > very-convenient-and-powerful cache system: > http://www.djangoproject.com/documentation/cache/ > > Also, the developers at grono.net, a Polish social networking site with > more than half a million users, have converted various bits of their > Java code to Python/Django. They've found that Django is not only much > quicker (and more fun) to develop in, it's also *faster* than Java and > requires less hardware. E-mail me personally if you want their contact > information for direct testimonials; we'll be publishing some more > testimonials publically as we get closer to Django 1.0. > > I would never use TurboGears or Ruby on Rails over Django for any > performance-intensive Web app. In my opinion, both frameworks make some > poor design decisions regarding the importance of performance. > > Adrian > -- > Adrian Holovaty > holovaty.com | chicagocrime.org | djangoproject.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
In article <[EMAIL PROTECTED]>, Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote: > >- Do you have to interface with things like messaging-systems (a la JMS >specs), distributed transaction managers? If so, the only way to go >Python is Jython: Python for the JVM. Because AFAIK, there are no >interfaces for Python to the likes of IBM's MQSeries or for any >distributed transaction managers. What about http://www.zope.org/Members/tim_one/spread/ -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "19. A language that doesn't affect the way you think about programming, is not worth knowing." --Alan Perlis -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Ray wrote: > Yes, but this is more of a web application though--something that I've > never developed in Python before, so... I'll be evaluating Django > shortly--let me see how it compares to Tomcat. Performance is one of the key features of Django. For example, I'm using Django at washingtonpost.com for the U.S. Congress Votes Database, which has more than 4 million records and is linked-to from the washingtonpost.com home page whenever there's a key congressional vote. (http://projects.washingtonpost.com/congress/) The server doesn't break a sweat, thanks to Django's very-convenient-and-powerful cache system: http://www.djangoproject.com/documentation/cache/ Also, the developers at grono.net, a Polish social networking site with more than half a million users, have converted various bits of their Java code to Python/Django. They've found that Django is not only much quicker (and more fun) to develop in, it's also *faster* than Java and requires less hardware. E-mail me personally if you want their contact information for direct testimonials; we'll be publishing some more testimonials publically as we get closer to Django 1.0. I would never use TurboGears or Ruby on Rails over Django for any performance-intensive Web app. In my opinion, both frameworks make some poor design decisions regarding the importance of performance. Adrian -- Adrian Holovaty holovaty.com | chicagocrime.org | djangoproject.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Ray wrote: (snip) > But then on the other hand, there is a manpower problem--it's damn easy > to find a Java programmer (although the quality that you get is a > different matter). Python programmers are more difficult. Possibly - but if a programmer is not able to pick on Python in a matter of days, then it's a bad programmer that won't be of any help whatever the language. So in fact, choosing Python may help you get better programmers !-) > >>If I were you I'd concentrate on creating a website that actually >>works. Your chances of creating a website that needs to scale to be >>'heavyweight' are very slim. If you manage to get to that point then >>you can start worrying about how to cope with all the money that's >>rolling in ;) > > > You know what, this is a very good point :)) > > >>AFAIAA Python scales better than Java as any performance critical >>parts can be easily rewritten in C. To spend too much time worrying >>over it is premature optimisation though. > > > Yes, but this is more of a web application though--something that I've > never developed in Python before, so... I'll be evaluating Django > shortly--let me see how it compares to Tomcat. You may also want to have a look at turbogears (roughly similar to Django, but probably much more flexible) My 2 cents -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Tim N. van der Leeuw wrote: > Hi Ray, Hi Tim! > I'm in a bit of the same boat as you only I don't get to choose my > implementation language ;-) > > Some of the concerns should be: > - Do you have to interface with things like messaging-systems (a la JMS > specs), distributed transaction managers? If so, the only way to go > Python is Jython: Python for the JVM. Because AFAIK, there are no > interfaces for Python to the likes of IBM's MQSeries or for any > distributed transaction managers. Hmmm, at this level I think not. But yes, this is a good point, I'll keep this in mind. If it's gonna be Jython, I think I might as well go with J2EE--since it is yet another layer on top of a platform. > - Is your application purely a web-based application? Or is there a > large amount of application logic which is not tied to the web in any > way? Yes, it is purely a web-based application... well, it has a "administration" page, that the back office stuff, but that can be web-based as well. > - Python has a number of frameworks for developing server applications, > like Twisted, Zope and Django. > I don't know Twisted; I know a little bit about Zope. Zope has several > enterprise-level features and provides scalability/clustering. > However, I've found the learning-curve for Zope to be a bit steep so > far; too steep to master it in what little bits of spare time I have. > (If I would have more time I'd be able to get the hang of it but I > don't have enough time) Ah, yes... all respect to Zope, but I hope this is something that can be done in Django. I suspect the implementation time will be very, very short... as typical of the nature of these projects, and with the seeming intricacies of Zope, the impression of which I get from reading about it, I don't think we have the spare time/effort... > I've started to toy a bit with Django and it seems to get rather easy > to get started with developing a Web application using Django; however > I also get the feeling that installation is a bit more involved than > with Zope and that it will be not as easy to package up an application > and transport it to another machine, as it is with Zope. Thanks, this is a useful info. I'm about to evaluate Django deeper myself, how have you found it? Does it cover the whole "web" part of the J2EE stack, at least? (i.e.: it can replace Tomcat)? How has your experience been when you need to go further? (i.e.: beyond mapping data in DB to webpages)? > So for development of Web-applications, I would certainly consider > either Zope or Django. > Both offer ways to store your data in a transactional database; Django > has some object-relation mapper tools but I'm not sure how exactly Zope > stores data in a SQL database (it comes with it's own powerful > object-database, the ZODB but I don't know if OR mapping tools exist > for Zope). Hmm, I've never got the time to look at Zope proper, but my understanding is that Django is analogous to Tomcat, and Zope is analogous to a full blown appserver a la WebLogic, right? > So what are your requirements for 'J2EE' applications? And which Python > framework would best fit the bill? Hmmm, it's purely web-based, and I don't foresee message queueing and stuff at this point. I'll take a better look at Django. Thanks! Ray > > > cheers, > > --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Hi Ed, Ed Singleton wrote: > Personally I have found that if you need to sell a technology on, > saying it's written in Java is an advantage generally (because "it's a > standard"). If it's written in Python you may get asked why it has > been written in a "scripting language" if they've heard of it at all. Yes, I agree. Especially with those cover-my-ass types in big institutions who'd only go for things that have the word "Enterprise" on it :) > exactly the same tools as them, so you have to choose better tools. > Almost by definition, the tools that the majority are using are NOT > the best tools for the job. If I were you I'd definitely choose > Python, if only because everyone else is not using it yet. Yes, that was what I was thinking. Fast development cycle and ability to embrace change is crucial here. I do feel the way Java is getting in the way of my coding even after using Python for small personal projects. But then on the other hand, there is a manpower problem--it's damn easy to find a Java programmer (although the quality that you get is a different matter). Python programmers are more difficult. > If I were you I'd concentrate on creating a website that actually > works. Your chances of creating a website that needs to scale to be > 'heavyweight' are very slim. If you manage to get to that point then > you can start worrying about how to cope with all the money that's > rolling in ;) You know what, this is a very good point :)) > AFAIAA Python scales better than Java as any performance critical > parts can be easily rewritten in C. To spend too much time worrying > over it is premature optimisation though. Yes, but this is more of a web application though--something that I've never developed in Python before, so... I'll be evaluating Django shortly--let me see how it compares to Tomcat. > > (I'd love to develop in Python and get paid for it finally, but at the > > same time I do want to give the money guy the best value for his > > money...) > > The only thing you really need to be happy is to find something you > enjoy doing and to do it. Money is definitely secondary to that. If > you have a chance to be paid for working in Python, then go for it; > even if you fail, you will have spent your days in a happy state. Yeah, I have the chance to do that if I manage to get this through, but at the same time I do want to give the guy who funds us the best value possible for his money. (If--If--it means I have to use J2EE, I will do it.) Thanks, Ray > > Ed -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
On 11 Jan 2006 17:54:05 -0800, Ray <[EMAIL PROTECTED]> wrote: > Hello, > > I've got the chance to determine the technology to use in creating a > product similar to this: > > http://www.atomicisland.com/ > > Now the thing is that I need to sell this to the guy with the money. > I've developed for years with C++ and Java, last 7 years J2EE, and I'm > kinda sick of the "bloated" feeling that the whole J2EE/appserver > business carries into the picture. Personally I have found that if you need to sell a technology on, saying it's written in Java is an advantage generally (because "it's a standard"). If it's written in Python you may get asked why it has been written in a "scripting language" if they've heard of it at all. > Python is the language that I use at home, so I've been thinking of > using this to implement the product mentioned above. I've personally > experienced the pleasure of programming in it, and as such, I hope that > this will translate to advantage over our competitors (a la Paul > Graham's argument for Lisp). >From my brief look at that url you gave, it looks like you are trying to enter a very crowded market place. You will have to perform a lot better than your competitors in order to succeed (they have a head start on you). There's no way on earth you can do that by using exactly the same tools as them, so you have to choose better tools. Almost by definition, the tools that the majority are using are NOT the best tools for the job. If I were you I'd definitely choose Python, if only because everyone else is not using it yet. > That said, my experience with Python is limited to toy programs, that I > write myself for my own use. As such, I have several concerns: > > 1. How scalable is Python? In J2EE, when the load gets really big, we > can resort to clustering. Same goes about availability. Is there > anything that will help here in Python? (Mind, my Python experience is > usually with scripts and console). > > 2. If there is, what is the transition like from being lightweight to > heavyweight? E.g.: in J2EE we can use Tomcat at first as a lightweight > web container, and scale as necessary using a more powerful appserver. > Is this possible in Python? If I were you I'd concentrate on creating a website that actually works. Your chances of creating a website that needs to scale to be 'heavyweight' are very slim. If you manage to get to that point then you can start worrying about how to cope with all the money that's rolling in ;) AFAIAA Python scales better than Java as any performance critical parts can be easily rewritten in C. To spend too much time worrying over it is premature optimisation though. > 3. Have any of you done this before? As in you come from a heavy J2EE > background, and then switch to doing something equally serious in > Python? In your experience, in the end, did you find Python suitable at > all for this domain or you think you should have stuck to J2EE? What > are the pros and cons you discovered? I don't have much experience of Java tbh, but I've never heard of any pro's to using it, except for the fact that it's more acceptable to big business and it's easier to get mediocre programmers for it. > (I'd love to develop in Python and get paid for it finally, but at the > same time I do want to give the money guy the best value for his > money...) The only thing you really need to be happy is to find something you enjoy doing and to do it. Money is definitely secondary to that. If you have a chance to be paid for working in Python, then go for it; even if you fail, you will have spent your days in a happy state. Ed -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Hi Ray, I'm in a bit of the same boat as you only I don't get to choose my implementation language ;-) Some of the concerns should be: - Do you have to interface with things like messaging-systems (a la JMS specs), distributed transaction managers? If so, the only way to go Python is Jython: Python for the JVM. Because AFAIK, there are no interfaces for Python to the likes of IBM's MQSeries or for any distributed transaction managers. - Is your application purely a web-based application? Or is there a large amount of application logic which is not tied to the web in any way? - Python has a number of frameworks for developing server applications, like Twisted, Zope and Django. I don't know Twisted; I know a little bit about Zope. Zope has several enterprise-level features and provides scalability/clustering. However, I've found the learning-curve for Zope to be a bit steep so far; too steep to master it in what little bits of spare time I have. (If I would have more time I'd be able to get the hang of it but I don't have enough time) I've started to toy a bit with Django and it seems to get rather easy to get started with developing a Web application using Django; however I also get the feeling that installation is a bit more involved than with Zope and that it will be not as easy to package up an application and transport it to another machine, as it is with Zope. So for development of Web-applications, I would certainly consider either Zope or Django. Both offer ways to store your data in a transactional database; Django has some object-relation mapper tools but I'm not sure how exactly Zope stores data in a SQL database (it comes with it's own powerful object-database, the ZODB but I don't know if OR mapping tools exist for Zope). However you mentioned 'development in J2EE' and J2EE applications are by no means restricted to Web interfaces. J2EE applications can have rich GUI clients, or can be without any UI at all and exist just as message-driven beans triggered by messages coming in via JMS interfaces. I wouldn't know what Python frameworks exist that would combine web-based applications with tradional GUI client/server applications and I have no idea how to listen to a queue using Python... So what are your requirements for 'J2EE' applications? And which Python framework would best fit the bill? cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list
Help me in this please--is Python the answer?
Hello, I've got the chance to determine the technology to use in creating a product similar to this: http://www.atomicisland.com/ Now the thing is that I need to sell this to the guy with the money. I've developed for years with C++ and Java, last 7 years J2EE, and I'm kinda sick of the "bloated" feeling that the whole J2EE/appserver business carries into the picture. Python is the language that I use at home, so I've been thinking of using this to implement the product mentioned above. I've personally experienced the pleasure of programming in it, and as such, I hope that this will translate to advantage over our competitors (a la Paul Graham's argument for Lisp). That said, my experience with Python is limited to toy programs, that I write myself for my own use. As such, I have several concerns: 1. How scalable is Python? In J2EE, when the load gets really big, we can resort to clustering. Same goes about availability. Is there anything that will help here in Python? (Mind, my Python experience is usually with scripts and console). 2. If there is, what is the transition like from being lightweight to heavyweight? E.g.: in J2EE we can use Tomcat at first as a lightweight web container, and scale as necessary using a more powerful appserver. Is this possible in Python? 3. Have any of you done this before? As in you come from a heavy J2EE background, and then switch to doing something equally serious in Python? In your experience, in the end, did you find Python suitable at all for this domain or you think you should have stuck to J2EE? What are the pros and cons you discovered? (I'd love to develop in Python and get paid for it finally, but at the same time I do want to give the money guy the best value for his money...) Thanks much, Ray -- http://mail.python.org/mailman/listinfo/python-list