[Tutor] Information
Hi all, I would be working on a small project, which will include the SOAP library to use the web services using python. Also I want to know how to link XML to python. I mean suppose i am a client and i am accessing a server and suddenly it gives me an error which is being displayed on the website. I am working on something like this. I would code the client and server and when the client faces some problem it gets an error and uses the soap library to access the web services. I hope everybody can understand, if not clear I will ask my professor again and tell you exactly what does he want. Regards, Umair ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 106, Issue 5
>On Mon, Dec 03, 2012 at 05:56:30PM -0600, Luke Paireepinart wrote: > >> I just wanted to make the observation that, at least in gmail, the default >> behavior is to hide the entire quoted text behind an innocuous "..." >> button. > >Good lord, the more I hear about Gmail, the more horrible I discover it >to be. Why does anyone use this crappy, anti-social product? > To promote Google's information obesity? ;-) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 106, Issue 5
On Tue, 4 Dec 2012, Steven D'Aprano wrote: On Mon, Dec 03, 2012 at 05:56:30PM -0600, Luke Paireepinart wrote: I just wanted to make the observation that, at least in gmail, the default behavior is to hide the entire quoted text behind an innocuous "..." button. Good lord, the more I hear about Gmail, the more horrible I discover it to be. Why does anyone use this crappy, anti-social product? Because it didn't use to suck. Also protip: you can use with gmail. Like alpine ;) -Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] insufficient control of ossaudiodev and or wave modules
Opensuse 12.2 python3.2 I would like to set the to get better control of the play back of wave files. I would like to set the play back volume, send the audio out only one of the two speakers and ajust the play back speed. I am completely blank on ideas of how to accomplish this and reading the recommendation in the documentation suggesting that you should not try to rewrite part of the standard library by your self I have decided to ask how to go about this. Perhaps instead of reimplementing the library a new class should be created for basic audio manipulation. If so then how would I go about this? The wav file format is not exactly human readable. I have not seen anything similer to what I desire in the repo of 3rd party packages at the python web site. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] On understanding defintions
Opensuse 12.2 python3.2 I discoverd that some of the examples for definitions in the tutorial are not valid. I am reporting this as a bug. In the mean time I tried to look up definitions in the Language Referance part of the python documentation but I'm still confused. The if, for, etc. are statements of evaluation, comparing one item to another; so what does that make definitions? What is self? How are definitions properly used? What are the mandetory parts? What are the optional parts? (in if statements the optional parts are or, and, elif, else, etc.) I also tried looking into the demos directory, I found lots of definitions but little help in understanding them. I am confused on all types of definitions not just functions or classes. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] On understanding defintions
On 04/12/12 18:29, frank ernest wrote: Opensuse 12.2 python3.2 I discoverd that some of the examples for definitions in the tutorial are not valid. I am reporting this as a bug. It's not clear what you mean by definitions here. In the mean time I tried to look up definitions in the Language Referance part of the python documentation but I'm still confused. The if, for, etc. are statements of evaluation, comparing one item to another; so what does that make definitions? I don't know what you mean by definitions? Can you give examples? What is self? See the OOP topic in my tutorial. But given your other remarks I suspect its a topic you should leave until later. How are definitions properly used? That depends on what you mean by definitions. What are the mandetory parts? What are the optional parts? (in if statements the optional parts are or, and, elif, else, etc.) No, 'or' and 'and' are not part of the if statement they are part of the *expression*. The expression is a mandatory part of the if statement. elif and else are optional. An expression is also mandatory with an elif I also tried looking into the demos directory, I found lots of definitions but little help in understanding them. I am confused on all types of definitions not just functions or classes. It sounds like you need to step back and start at the beginning. Do you know any other programming languages? If so, work through the official python tutor and ask specific questions here when you get stuck (with a reference to the relevant tutor section). http://docs.python.org/3/tutorial/index.html If not start with one of the Non Programmers tutorials - perhaps mine(see below)! :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] insufficient control of ossaudiodev and or wave modules
Hi, On 4 December 2012 18:20, frank ernest wrote: > Opensuse 12.2 python3.2 > I would like to set the to get better control of the play back of wave > files. I would like to set the play back volume, send the audio out only > one of the two speakers and ajust the play back speed. I am completely > blank on ideas of how to accomplish this and reading the recommendation in > the documentation suggesting that you should not try to rewrite part of the > standard library by your self I have decided to ask how to go about this. Perhaps instead of reimplementing the library a new class should be created > for basic audio manipulation. > If so then how would I go about this? > The wav file format is not exactly human readable. > I have not seen anything similer to what I desire in the repo of 3rd party > packages at the python web site. > Manipulating a Wav file or the data in a wav file is not the same thing as controlling the audio hardware & audio mixer on your computer. You can change the playback volume of a file by either changing the file data before playback, or by controlling the mixer during playback. You seem to be slightly conflating these 2 things. So what is it you're trying to do in reality? Control the volume of playback or manipulate an existing WAV file in terms of the volume (amplitude) of the audio waveform in the file? Anyway, the mixer volume can be controlled with the oss_mixer_device object (using methods set() and get()) which is part of the ossaudiodev model you've already found. As for actually getting data into and out of wave files (reading data from them, and writing them), that's what the wave module is useful for. However it doesn't provide much if anything in the way of actually manipulating audio -- it's only use is to hide the detail of the Wav file, allowing you to get the raw data in the file and write it without having to worry about the actual Wav format. For more complex audio transformations you might consider the pysox module in conjunction with the sox library: http://pypi.python.org/pypi/pysox As a bit of background: "Sox" is a very capable sound manipulation program which is basically a wrapper over the underlying programming library called "libsox". "pysox" then is a Python wrapper for libsox that allows you to use it from within Python. It's probably the easiest way to do "standard"-ish transformations on sound files. Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Information
On 04/12/12 08:38, Umair Masood wrote: Hi all, I would be working on a small project, which will include the SOAP library to use the web services using python. This list is for teaching the basics of the Python language and standard library. There is no SOAP library in Python. You will need to be more specific about what you are trying to do and what libraries you are using. link XML to python. I mean suppose i am a client and i am accessing a server and suddenly it gives me an error which is being displayed on the website. I am working on something like this. I would code the client and server and when the client faces some problem it gets an error and uses the soap library to access the web services. There are libraries to call web services that you can download. There are also libraries for parsing XML. Of the ones in the standard library etree is probably the best option. If you can already program in Python you may find these useful as a starter: http://www.diveintopython.net/soap_web_services/index.html http://docs.python.org/3/library/xml.etree.elementtree.html#module-xml.etree.ElementTree -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] On understanding defintions
On 12/04/2012 01:29 PM, frank ernest wrote: > Opensuse 12.2 python3.2 > I discoverd that some of the examples for definitions in the tutorial are > not valid. I am reporting this as a bug. And what are the bug numbers? Or links to the bug reports? Otherwise why are you telling us about them without mentioning any details? > In the mean time I tried to look up definitions in the Language Referance > part of the python documentation but I'm still confused. The if, for, etc. > are statements of evaluation, comparing one item to another; so what does > that make definitions? "Definitions" is an English word. How do you mean it here? Are you perhaps referring to the 'def' keyword? Or to assignment? Or to the 'with' statement. Or to the 'lambda' expression. > What is self? 'self' is a convention used in naming the special instance argument in instance methods. This allows a special syntax for supplying that first argument. 'cls' is a similar convention for the class argument in class methods. Static methods have no special argument. 'self' is roughly analogous to 'this used in C++ and Java, with the main difference being that it's never implied. > How are definitions properly used? > What are the mandetory parts? > What are the optional parts? (in if statements the optional parts are or, > and, elif, else, etc.) 'if', 'elif' and 'else' are statements. 'and' and 'or' are entirely different; they are operators, and have nothing to do with those three statements. The first two of those three statements take an expression, which may or may not include an operator, or twenty five operators. Nothing special about 'and' nor 'or' (nor '+', or '^' nor ...) > I also tried looking into the demos directory, I found lots of definitions > but little help in understanding them. > I am confused on all types of definitions not just functions or classes. > > Perhaps if you gave us some idea of your background, we'd have a better idea at what level to aim our discussion. For questions like this, I'd personally start with the bnf for the language, if you have the background to understand it. I first learned bnf over 40 years ago, and it's still useful for learning a new language. http://docs.python.org/3.4/reference/grammar.html On the other hand, if this is your first language, it's totally the wrong level to start. I had 4 under my belt before taking the compiler design class that introduced bnf. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] I'm trying to wrap my head around defs
Opensuse 12.2 python3.2 I'm having trouble understanding them. Python is my first language... excluding English. I've already read ALL OF THE PYTHON Language Referance and I still don't "get it." What do they do? How do they work? How do you define self? Is self an object, a variable, or what? How about some over commented examples? The if statement is a statement of comparison. what is a def and more specifically a class? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] On understanding defintions
(responding on-list to an offline question) On 12/04/2012 04:18 PM, do...@mail.com wrote: > Here's a better question. When is it appropriate to use a def statement? > Welcome to the Python tutor mailing list. A function is usually defined by a def statement and the suite of indented lines that follow. (There are other ways to get a function object, including lambda, but that's an advanced topic) A function may be called from other places in the code, and optionally arguments may be passed to that function and/or returned from that function. There are many reasons to wrap one or more lines of code into a function and call it, but the most important is one of clarity. If you give it a good name, and understand what it does, then the place where it is called becomes easier to understand. For example, somebody wrote the function math.tan(). It takes one argument, and returns one result. And the work it does is to calculate a tangent of an angle given in radians. The function is not part of python the language, but it is part of the standard library. When I write a program that needs that work done, rather than including the complexity in each place, I refer to the one that was written (by someone else), and my code is much clearer for it, because anyone reading my code knows (or can find out) what math.tan() does. The same applies for some code you write strictly for your own use. Even if the whole program is in one file, it's still useful to encapsulate it into distinct parts, most of which perform some fairly simple set of operations. A second reason is shortening of the code. If you write a (non-trivial) function once, and call it from ten places, then your code is shorter by 9 copies of the function's body, more or less. That might not sound like a big deal, but it also means that if you find a problem with the algorithm, you can fix it in one place, and not have to hope that you got all ten places where you made the same error. Your next question is apparently what the elements of the 'def' statement mean. The simplest type of function might be like: def print_separator(): print ("--") This function takes no arguments, and returns no results. But it does something useful. You call it with print_separator() So you might have a set of code something like print(value1) print_separator() print(value2) print_separator() print(math.tan(value99) Let's suppose you later decided to change the dashes to some other character. You could just change the body of the def, and all the calls would use the new string. But most functions take one or more arguments. So let's add some formal parameters to our definition. For now, we'll just use positional parameters (leaving keyword parameters for chapter 6). def print_separator(size): print("-"*size) #print 'size' copies of the character '-' This takes one argument and binds it to the formal parameter size. Then size can be used inside the function, without caring how it was produced. Now you can produce a different sized separator just by varying the argument to this function. print(value1) print_separator(40) print(value2) print_separator(10 * len(value2)) print(math.tan(value99) Now, you could add a second parameter to the function, by just adding a comma and name): def print_separator(size, char): print(char * size) #print 'size' copies of the specified character Now the caller can specify both. And in fact MUST supply both. If that's undesirable, then you can give defaults to one or both. def print_separator(size=10, char="-"): Now, if it's called with no arguments, it works like the first one. If it's called with one, it better be an integer. And if it's called with two, the first better be an integer and the second a string. No idea if that's what you wanted, but if you want much more, you should be working through a tutorial. Be sure the version of tutorial matches the version of Python you're using. Same is true of those examples you found "bugs" in. Could be the page they're on was meant for a different version of Python than what you're running. For example, in Python 2.x, 'print' was a statement, while in 3.x it's a function. >> - Original Message - >> From: Dave Angel >> Sent: 12/04/12 02:19 PM >> To: frank ernest >> Subject: Re: [Tutor] On understanding defintions >> >> On 12/04/2012 01:29 PM, frank ernest wrote: >>> Opensuse 12.2 python3.2 >>> I discoverd that some of the examples for definitions in the tutorial are >>> not valid. I am reporting this as a bug. >> >> And what are the bug numbers? Or links to the bug reports? Otherwise >> why are you telling us about them without mentioning any details? >> To log a bug, or search for an existing one, go to http://bugs.python.org/ . Searching there, i don't see any bugs logged by you. So what did you mean by report? If there are legitimate bugs, they certainly should be report
Re: [Tutor] On understanding defintions
On 05/12/12 05:29, frank ernest wrote: Opensuse 12.2 python3.2 I discoverd that some of the examples for definitions in the tutorial are not valid. I am reporting this as a bug. Don't be shy, let us know the ticket numbers :) I've looked on the bug tracker and can't see any sign of your bug report: http://bugs.python.org/ But I think that before you report this as a bug, you ought to get agreement from others that it is a bug. How about you link to the page in the tutorial that you think is not valid, and tell us what parts are not valid? In the mean time I tried to look up definitions in the Language Referance part of the python documentation but I'm still confused. The if, for, etc. are statements of evaluation, comparing one item to another; so what does that make definitions? Frank, are you a native English speaker? This is a multinational forum and we have many people here to whom English is their second, or third, language. It isn't clear to me whether you are having trouble understanding the English word "definition", or whether you don't understand some of the *specific definitions* of Python terms. Perhaps you could try explaining your problem again, in a little more detail. What is self? "self" is a function parameter which is automatically provided by the Python interpreter when you call a method. Does that help? Have you programmed using object-oriented programming before? Do you have any previous programming experience? It is hard to know what level of explanation you need. How are definitions properly used? I'm sorry, I don't understand your question. What are the mandetory parts? "Mandatory" means that something is compulsory, that it must be present. For example, Python has an "if...elif...else" statement: if x > 100: print("x is larger than one hundred") elif x < 10: print("x is smaller than ten") else: print("x is between ten and one hundred") In this case, the "if" part is *mandatory* -- it must be there, or you don't have an "if" statement at all. But the other two parts, the "elif" and "else" parts, are optional. # "elif" or "else" on its own is NOT allowed, since "if" is # mandatory but not given. This will give a SyntaxError: else x < 0: print("x is negative") # On the other hand, "if" on its own is allowed, since the # other parts are optional. if x < 0: print("x is negative") I am confused on all types of definitions not just functions or classes. I'm not going to try to guess what things confuse you. Please pick *one* concept that confuses you, one at a time, and ask about it. We can that explain that. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I'm trying to wrap my head around defs
On Tue, Dec 4, 2012 at 4:51 PM, frank ernest wrote: > Opensuse 12.2 python3.2 > I'm having trouble understanding them. > Python is my first language... excluding English. > I've already read ALL OF THE PYTHON Language Referance and I still don't > "get it." > What do they do? Let's start simple. It is a Python keyword to define a function. > How do they work? Just like a function in mathematics, they take some arguments, do stuff with it (hopefully) and more than likely return something. For example, cos(angle) defines the cosinus calculation for a given angle. This function is an object that has been defined at some point by a def cos(angle): So there is a difference between *def*ining a function and using it, hence the def keyword. > How do you define self? You do not. It is related to scope, > The if statement is a statement of comparison. what is a def and more > specifically a class? You really need to understand functions first, then scope, then we can talk class. So, my question to you before we get too far, are you ok with the concept of mathematical functions? Francois -- www.pyptug.org - raspberry-python.blogspot.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I'm trying to wrap my head around defs
On 04/12/12 21:51, frank ernest wrote: Opensuse 12.2 python3.2 I'm having trouble understanding them. Python is my first language... excluding English. OK, in that case go back to basics. Don't read the reference manual, that's like trying to learn English by reading the Oxford English Dictionary. Its a great reference but its not a tutorial. Go to the Non Programmers page and use one of the tutorials there. They all have slightly different styles so pick the one that looks to make most sense to you. Mine if you like it! :-) I've already read ALL OF THE PYTHON Language Referance and I still don't "get it." I'm not surprised, it's designed for people who know how to program in Python to understand the internal details. Even the official tutorial assumes you already know the basic concepts of programming. That's why you need to go to the Non programmers page. They assume you know nothing beyond computer basics (how to create a text file, navigate the file structure and run a program). What do they do? How do they work? The tutorials will explain. How do you define self? The tutorials should explain. Dave already has, but I doubt you followed his explanation. Is self an object, a variable, or what? Yes, its both an object and a variable. Specifically its a name that refers to an object. But you don't need to worry about self yet, you need to go back to the beginning. How about some over commented examples? The tutorials should provide that. The if statement is a statement of comparison. what is a def and more specifically a class? A def is how to define a function, which is a reusable piece of code. A class is how to define a class which is a template for a set of objects. But the tutorials should explain all of that. Seriously, go through some of the tutorials. If you get stuck come back here with specific questions and references to the tutorial material you are stuck with. It may seem tedious but it is the fastest way in the long run. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I'm trying to wrap my head around defs
On 12/04/2012 04:51 PM, frank ernest wrote: > Opensuse 12.2 python3.2 > I'm having trouble understanding them. > Python is my first language... excluding English. > I've already read ALL OF THE PYTHON Language Referance and I still don't > "get it." You usually should start with a tutorial, not with a reference. A reference assumes some working knowledge, either from previously doing a tutorial, or from many other languages where you're really just looking for differences. You also need to make sure that the version of both tutorial and reference matches your version. Otherwise you'll needlessly confuse yourself with differences. This is especially true between Python 2.x and 3.x. http://docs.python.org/3.2/tutorial/ > What do they do? > How do they work? A function definition defines a section of the code that can be called from multiple places. Each time it's called, control transfers to the function's first line, and continues till the function returns. Then control continues on the line that contained that function call, possibly returning a value to be used in that expression. > How do you define self? > Is self an object, a variable, or what? 'self' is a common convention for the first formal parameter to an ordinary class method. But since 'class' is an advanced topic, you'd do far better to defer thinking about it. > How about some over commented examples? Using the first example of section 4.6 ("Defining Functions") from that tutorial I gave you a link for. def fib(n):# write Fibonacci series up to n """Print a Fibonacci series up to n.""" a, b = 0, 1 #build a tuple of (0,1). Unpack it to the names a and b, respectively #equiv. to a=0; b=1 while a < n:#starts a loop, which will repeat until a >= n print(a, end=' ') #print current value of n, but without a newline a, b = b, a+b#build a tuple (b, a+b), and then unpack it to a and b print()#print a newline > The if statement is a statement of comparison. what is a def and more > specifically a class? > The 'if' statement has nothing to do with comparison. It simply arranges conditional change in the order of execution, based on the "truthness" of an expression. In other words, instead of proceeding in sequential order, the interpreter skips over either the then-portion or the else-portion, depending on how the expression evaluates. The most common USE of an 'if' statement will be of some form like: if x<10: But understand that 'if' doesn't care, as long as the expression can produce a boolean. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with web.py error
Hi, I need some help tracking the cause of this error. I have been looking at Python off and on for the last year or so. I write ASP classic and VB6 as my day job (yeah, I know.., it pays the bills). So some of this may be me have to think differently. I have tried the web.py group with no answer. I am probably not asking the right question or they think it is a SQLlite error. Here is the complete traceback Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 239, in process return self.handle() File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 230, in handle return self._delegate(fn, self.fvars, args) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 420, in _delegate return handle_class(cls) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 396, in handle_class return tocall(*args) File "Code.py", line 24, in GET todos = db.select('todo') File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/db.py", line 682, in select return self.query(qout, processed=True) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/db.py", line 1030, in query out = DB.query(self, *a, **kw) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/db.py", line 644, in query self._db_execute(db_cursor, sql_query) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/db.py", line 587, in _db_execute out = cur.execute(query, params) File "/usr/lib/python2.7/sqlite3/dbapi2.py", line 63, in convert_date return datetime.date(*map(int, val.split("-"))) ValueError: invalid literal for int() with base 10: '21 01:47:43' 127.0.0.1:59850 - - [04/Dec/2012 22:47:35] "HTTP/1.1 GET /" - 500 Internal Server Error I understand the error, there is no way '21 01:47:43' can become an int. What I can not figure out is the correlation between the last two lines in the traceback. What is actually calling the last command 'datetime.date'? Here is another kicker, I have tesed this on 4 computers, all with Python 2.7 and the lastest web.py egg. One of the computers works without an error. I did some additional testing by hijacking db.py and adding text to line 587 that would normally cause a meltdown. I can say that on the working computer the function datetime.date is not being called. Why on one computer and not the others. I know the code is the same becuse the files are synced via DropBox on all 4 machines. I have also written a test script that calls the SQLite lib directly and opens a connection and recordset. This works on all 4 machines. All of my code for this is here on this shared dropbox folder. Code.py is the stater file for web.py https://www.dropbox.com/sh/1zqjgtj86q033r8/LBgzPx-kLq Thanks, Erik Martinson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor