Re: [Tutor] python reverse engineering tools
It's not free, but I have had good success with Enterprise Architect from Sparx Systems (http://www.sparxsystems.com.au/). It will generate class diagrams from Python, C/C++, C#, Java. It also supports the full complement of UML diagrams - sequence diagrams are a special treat when you just drag a message arrow and get a drop-down list of the defined interface on the target object. When you go to their website, they refer to several license levels - here is the Rosetta Stone for figuring out what you want: http://www.sparxsystems.com.au/products/ea/editions.html. The low-end Desktop version is pretty stripped down, you will need to get at least the Pro level to get the reverse engineering feature. (We use the Pro edition at our office.) There is an academic Pro license for US$105, and there is an annual fee for getting updates. We use it at work to generate class diagrams during design, review, and as part of the code handoff to our clients. It's also great for reverse engineering when you get handed an only-partially-documented API, or a big mess of source code. There is also a free trial, so you could download that and try your hand at reverse engineering some Python code - maybe an existing package like PIL or something. Sadly, I've even used it to reverse engineer some of my *own* C# code - it was a project I hadn't touched for about 2 years, and the generated diagrams were a useful memory jogger as to what I had put where. (If you have ever downloaded pyparsing, the included class diagrams were created using EA - by hand, unfortunately, as Python support had not yet been added when I first started creating these diagrams.) -- Paul ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python question
On Fri, Nov 21, 2008 at 1:31 PM, Daniel J Kramer <[EMAIL PROTECTED]> wrote: > Hi > > I have just joined this list. I need some help working on a Python > application I am working on. I am working on a quiz game where the users > gain points when the answer questions correctly. I have written the > skeleton of the quiz with If, Elif and Else statements. it runs perfectly. > > I am very unclear on how to score points at the end of each round and how to > import images. > > Can anyone help out here or have any ideas on the best way to execute this? > I have included a copy of the quiz so you can get an idea of what I am > trying to do David has given you a hint about scoring points. Images are more difficult because you can't display an image directly in the console, you have to use a GUI toolkit. The EasyGUI buttonbox might do what you need, or provide a starting point for customization: http://easygui.sourceforge.net/tutorial.html#contents_item_9.4 Some tips about your program: Rather than checking for upper- and lower-case versions of the answer, you can convert the answer to lowercase and just check once, for example A11 = raw_input("...") A11 = A11.lower() Do you know about lists and loops yet? Your program would be much simpler if you kept the questions and answers in a list. For each question, you could store question text answer1, answer1 response, answer1 score answer2, answer2 response, answer2 score default response Then your code would just loop over the questions. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] extend my re
Hi, I've got a half working re but I can't find a way to give it the final touch. Let's say I have (it would actually be source code file) : >>> import re >>> MyString = """Algo ... Start ... otro ... comment ... otro ... comment ... comment ... otro ... end ... """ >>> MyPattern = re.compile(r'(.*?Start.*?)((comment.*?)*)(comment)(.*?end)', re.S) >>> print MyString Algo Start otro comment otro comment comment otro end >>> print MyPattern.sub(r'\1\2/*\4*/\5', MyString) Algo Start otro comment otro comment /*comment*/ otro end Which is basically ok. I have to find the last "comment" in the block and comment it. But I'd like to comment the whole line, my desired output would be : Algo Start otro comment otro comment /*comment*/ otro end And if there was something after the "comment" I would also like it to be commented : from: comment and something else to : /* comment and something else*/ any help? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Size of Python Console
Title: Signature.html How do I make the console window bigger? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) 'That's one small step for a man; one giant leap for mankind.' Neil Armstrong A thin man ran... makes a large stride... left planet... pins flag on moon... on to Mars! Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Size of Python Console
Title: Signature.html Correct. Now that we are engaged in a, perhaps dialectic, dialog I'm using Win XP with Python 2.5, and am using IDLE. Further, I would like to know how to do this with a Python program that I've distributed to users who know nothing about IDLE. That is, they simply click on the py file, and bring up the program. A console appears. I want it to be bigger than the default. Rod Hamby wrote: Im assuming youre talking about IDLE? If so when IDLE is open go to: options/configureIDLE. In there are all the font sizes, highlights,Hot key setups. Maybe next time more info example: In running IDLE on LInux XYZ IDLE verision123 and trying to.. You will get a better response from the group. Rod On Sat, Nov 22, 2008 at 6:43 AM, Wayne Watson <[EMAIL PROTECTED]> wrote: How do I make the console window bigger? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) 'That's one small step for a man; one giant leap for mankind.' Neil Armstrong A thin man ran... makes a large stride... left planet... pins flag on moon... on to Mars! Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) 'That's one small step for a man; one giant leap for mankind.' Neil Armstrong A thin man ran... makes a large stride... left planet... pins flag on moon... on to Mars! Web Page: ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] pylab Failure
Title: Signature.html Pylab runs fine under 2.5, and I've since moved there. Wayne Watson wrote: I copied the following code from a matplotlib tutorial, and it fails. I'm using python 2.4 on Win XP. It's matplotlib-0.98.3.win32-py2.4exe. With or without the finish function it fails in IDLE with. ... -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) 'That's one small step for a man; one giant leap for mankind.' Neil Armstrong A thin man ran... makes a large stride... left planet... pins flag on moon... on to Mars! Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Size of Python Console
On Sat, Nov 22, 2008 at 9:43 AM, Wayne Watson <[EMAIL PROTECTED]> wrote: > How do I make the console window bigger? On Windows click on the window icon (top left) and pick Properties. There are lots of goodies in there including window size and buffer size (how much the window will scroll). Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] the sense of brackets
I have long thought "[]" /simply/ is a list constructor syntax. What do you think of the following? t = "aze" print t, list(t), [t] print list(list(t)), list([t]), [list(t)], [[t]] ==> aze ['a', 'z', 'e'] ['aze'] ['a', 'z', 'e'] ['aze'] [['a', 'z', 'e']] [['aze']] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Size of Python Console
Title: Signature.html Very good, but is there a way I can begin with something other than the default? It's an inconvenience to the user to do this every time. As I recall distantly in XWin days they had something one could put in the command line that would specify the size. Kent Johnson wrote: On Sat, Nov 22, 2008 at 9:43 AM, Wayne Watson <[EMAIL PROTECTED]> wrote: How do I make the console window bigger? On Windows click on the window icon (top left) and pick Properties. There are lots of goodies in there including window size and buffer size (how much the window will scroll). Kent -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) 'That's one small step for a man; one giant leap for mankind.' Neil Armstrong A thin man ran... makes a large stride... left planet... pins flag on moon... on to Mars! Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] extend my re
Marco Catunda wrote: > Ricardo, > > Try this pattern > > MyPattern = > re.compile(r'(.*?Start.*?)((^.*?comment.*?)*)(^.*?comment)(.*?end)', > re.S | re.M ) > > Almost did it. But if there was something after and in the same line of the "comment" I want commented it wouldnt be taken. from : comment xxx to : /*comment*/ xxx and I wanted : /*comment xxx*/ But it helped a lot, I finally got : >>> MyPattern = re.compile(r'(.*?Start.*?)((^.*?comment.*?)*)(^.*?comment.*?$)(.*?end)', re.S | re.M ) which did the trick. Thanks a lot Marco! > On Sat, Nov 22, 2008 at 12:52 PM, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: > >> Hi, I've got a half working re but I can't find a way to give it the >> final touch. >> Let's say I have (it would actually be source code file) : >> > import re > MyString = """Algo > >> ... Start >> ... otro >> ... comment >> ... otro >> ... comment >> ... comment >> ... otro >> ... end >> ... """ >> > MyPattern = > >> re.compile(r'(.*?Start.*?)((comment.*?)*)(comment)(.*?end)', re.S) >> >> > print MyString > >> Algo >> Start >>otro >>comment >>otro >>comment >>comment >>otro >> end >> >> > print MyPattern.sub(r'\1\2/*\4*/\5', MyString) > >> Algo >> Start >>otro >>comment >>otro >>comment >>/*comment*/ >>otro >> end >> >> Which is basically ok. I have to find the last "comment" in the block >> and comment it. But I'd like to comment the whole line, my desired >> output would be : >> Algo >> Start >>otro >>comment >>otro >>comment >> /*comment*/ >>otro >> end >> >> And if there was something after the "comment" I would also like it to >> be commented : >> from: >>comment and something else >> to : >> /* comment and something else*/ >> >> any help? >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> >> > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Size of Python Console
"Wayne Watson" <[EMAIL PROTECTED]> wrote is there a way I can begin with something other than the default? It's an inconvenience to the user to do this every time. Create a shortcut that specifies the window parameters. (use properties and adjust the font and layout tab settings) Distribute the shortcut with the program. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] extend my re
"Ricardo Aráoz" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I've got a half working re but I can't find a way to give it the final touch. Let's say I have (it would actually be source code file) : import re MyString = """Algo ... Start ... otro ... comment ... otro ... comment ... comment ... otro ... end ... """ MyPattern = re.compile(r'(.*?Start.*?)((comment.*?)*)(comment)(.*?end)', re.S) print MyString Algo Start otro comment otro comment comment otro end print MyPattern.sub(r'\1\2/*\4*/\5', MyString) Algo Start otro comment otro comment /*comment*/ otro end Which is basically ok. I have to find the last "comment" in the block and comment it. But I'd like to comment the whole line, my desired output would be : Algo Start otro comment otro comment /*comment*/ otro end And if there was something after the "comment" I would also like it to be commented : from: comment and something else to : /* comment and something else*/ any help? A quick attempt that works for your example: MyPattern = re.compile(r'(.*?Start.*?)((\n\s*comment.*?)*\n)(\s*comment.*?)(\n.*?end)', re.S) You might look into something like pyparsing instead of a complicated re. -Mark ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] the sense of brackets
On Sat, Nov 22, 2008 at 9:42 AM, spir <[EMAIL PROTECTED]> wrote: > I have long thought "[]" /simply/ is a list constructor syntax. > What do you think of the following? > > t = "aze" > print t, list(t), [t] > print list(list(t)), list([t]), [list(t)], [[t]] > ==> > aze ['a', 'z', 'e'] ['aze'] > ['a', 'z', 'e'] ['aze'] [['a', 'z', 'e']] [['aze']] Consider the following: In [1]: list("Hello") Out [1]: ['H', 'e', 'l', 'l', 'e', 'o'] and the list docstring: list() -> new list list(sequence) -> new list initialized from sequence's items so list(list(t)) makes perfect sense: list(t) is ['a', 'z' ,'e'] and list(list(t)) simply creates a new list initialized from that list's items HTH, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python question
Some comments on your code, after David & Kent: * repetition You have probably noticed that your programm repeats over and over the same pattern, that could be called "process of a question". One major point of programming is precisely to cope with such a repetitive task (this was true even before electronics was invented with mechanical programms!). The trick is to write down the overall pattern, and then use it each time it is needed. It will build a kind of brick that you have to put inside a function to be able to call it. Ask us if you need help or tips for that. * main script There seems to be a kind of script that guides the progression of your quizz (esp. when music comes into play, sic:-)). This, not the repetition of questions, can form the main part of your programm. From there would then be called the question-process function. If there is no real change instead, no progression, then this main prog simply is a loop, as Kent says. You just need to define a way to get out of it! Meaning when/why/how to quit the programm? Both of these points lead you to *structure* your code. Presently your programm is 'flat'; meaning it has not yet a shape that shows off its logic. When a programm is properly organised, then its shape looks like what it does. And it tells the reader -- yourself, first -- about it. * text Get rid of all that mass of text! There are several ways to do that: -1- Give each of your texts a name (Qn,An,...). Use these names to program the logic. Associate a value to all of these names, creating 'constants', at e.g. the head of your programm. -2- Do the same, but in a separate file, called a 'module'. Then import this module at start. If you need help for that, ask. -3- When everything works good, then an interesting challenge may be to make your set of texts be a real text file. Much better to manage and edit. You need to write a fonction that is able to cope with a file, read it, analyse it, properly process the data hidden in it... Denis Daniel J Kramer a écrit : > Hi > > I have just joined this list. I need some help working on a Python > application I am working on. I am working on a quiz game where the users > gain points when the answer questions correctly. I have written the > skeleton of the quiz with If, Elif and Else statements. it runs perfectly. > > I am very unclear on how to score points at the end of each round and how to > import images. > > Can anyone help out here or have any ideas on the best way to execute this? > I have included a copy of the quiz so you can get an idea of what I am > trying to do > > thank you so much and I look forward to hearing from you soon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] the sense of brackets
W W a écrit : > On Sat, Nov 22, 2008 at 9:42 AM, spir <[EMAIL PROTECTED]> wrote: > >> I have long thought "[]" /simply/ is a list constructor syntax. >> What do you think of the following? >> >> t = "aze" >> print t, list(t), [t] >> print list(list(t)), list([t]), [list(t)], [[t]] >> ==> >> aze ['a', 'z', 'e'] ['aze'] >> ['a', 'z', 'e'] ['aze'] [['a', 'z', 'e']] [['aze']] > > Consider the following: > In [1]: list("Hello") > Out [1]: ['H', 'e', 'l', 'l', 'e', 'o'] > and the list docstring: > list() -> new list > list(sequence) -> new list initialized from sequence's items > so list(list(t)) makes perfect sense: list(t) is ['a', 'z' ,'e'] and > list(list(t)) simply creates a new list initialized from that list's items > HTH, > Wayne Yep! What surprises me is the behaviour of [] instead. I can understand that list(t) != [t] but [list(t)], [[t]] --> [['a', 'z', 'e']] [['aze']] is a bit strange to me. denis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] the sense of brackets
On Sat, Nov 22, 2008 at 10:42 AM, spir <[EMAIL PROTECTED]> wrote: > I have long thought "[]" /simply/ is a list constructor syntax. list(x) and [x] are not equivalent, as you have discovered. list(x) requires that x is a sequence - something that can be iterated - and it makes a new list out of the elements of the sequence. If x is not iterable then list(x) is an error; for example In [10]: list(1) TypeError Traceback (most recent call last) /Users/kent/ in () TypeError: 'int' object is not iterable OTOH [x] just takes whatever x is and makes it the single element of a list. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python question
On Sat, Nov 22, 2008 at 2:39 PM, spir <[EMAIL PROTECTED]> wrote: > -1- Give each of your texts a name (Qn,An,...). Use these names to program > the logic. Associate a value to all of these names, creating 'constants', at > e.g. the head of your programm. > -2- Do the same, but in a separate file, called a 'module'. Then import this > module at start. If you need help for that, ask. If you give names to each separate question you will still end up with a lot of similar code, even if it is just a function call like score += ask_question(Q1, A1A, A1B) Better is to think about structuring the data into lists and processing in a loop. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Regular expression oddity
Hi tutors! While trying to write a regular expression that would split a string the way I want, I noticed a behaviour I didn't expect. >>> re.findall('.?', 'some text') ['s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't', ''] Where does the last string, the empty one, come from? I find this behaviour rather annoying: I'm getting one group too many. Regards, Emmanuel ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Regular expression oddity
Emmanuel Ruellan wrote: Hi tutors! While trying to write a regular expression that would split a string the way I want, I noticed a behaviour I didn't expect. re.findall('.?', 'some text') ['s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't', ''] Where does the last string, the empty one, come from? I find this behaviour rather annoying: I'm getting one group too many. The ? means 0 or 1 occurrence. I think re is matching the null string at the end. Drop the ? and you'll get what you want. Of course you can get the same thing using list('some text') at lower cost. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor