4,305 Posted Topics
Re: Interesting project, but I need a little more info. What does your code look like and your text file? | |
Re: You could convert your total e-mail message to a list of lines and then remove the first couple of lines. I assume that's what you want. | |
Re: Whatever is between the triple quotes is one string and not part of the statement indentation rules. I guess you figured that out by trial and error, good way to do it! | |
Re: I see what you mean. Looks like you have to print the elements of the list to get the right result ... [php]a = u'\u05e9\u05dc\u05d5\u05dd!' print a print print mylist = ["qwerty","uiop",a] print mylist print mylist[2] # or for word in mylist: print word [/php] Making a dictionary should work, … | |
Re: Python, being a rather international programming language has unicode handling built in, but your much more local operating system might not be so international and rudely stop after the first 256 characters. | |
Re: In my humble opinion C is the grandma of C++. Do you really want to send her to the old folks home? Maybe it's time to give her a little rest from all those C++ things that just make her head spin anyway. ![]() | |
Re: Tuples are handy for transferring multiple data, for instance to and from a function. They are easy to construct and transfer and assign their data easily. Check the multiReturn() example in the "Starting Python" sticky to see what I mean. | |
Re: Many times you can insert a temporary print statement to show what is going on. Here a test print inside the loop ... [code]import random # create a sequence of words to choose from WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone") # pick one word randomly from the sequence … | |
Re: I think you have other problems. There are two (Java?) functions you used that are not part of Python. getMax(ls) If variable ls is a list then max(ls) will give you the maxium element of the list. isDivisible(Max,x) I need a more detailed explanation of its purpose. What does it … | |
Re: The comma will automatically add a space. Better use this formatted print statement: [php]print "the total price of the car with all extras and tax is: $%d" % (base_price+under_coat+stereo+air+tax) [/php] | |
Re: Add the test line print "/var/www/stretch/web_root/SidCrops/"+Customer+"/"+DataRecord before WorkingFile = open("/var/www ... What comes up as full file path? I know that spaces in a folder or filename are trouble! | |
Re: I use ConTEXT a lot, it is free, relatively small, fast and reliable. It does highlight Python, and you can configure it to run your code from the editor. Download from: [url]http://www.context.cx/[/url] | |
Re: In your Python folder there is a folder \lib\test\ that should give you an idea how the Pythonians do their testing of modules. It looks like you might need to write a simple test program. Also IDEs like IDLE have a check module option. Hope someone else knows more about … | |
Re: How about a distance converter with a menu driven convert from/to. For instance convert light-years to miles, or millimeters to inches, yards to rods and so on. | |
| |
Re: You did the right thing, keep telling me what is going on, and together we can straighten this beginner problem out. You are not only learning to use Python, but also how to use the IDLE IDE properly. The learning curve is a little steep there. I tried to recreate … | |
Re: A C++ Interpreter, that should be a fun project! One way to genuinely learn C++. | |
Re: I ran a quick test and on my Windows XP Box it seems to be the file path it balks at. I had to give it the full file path (or at least back to where python.exe sits) [code=python] try: # needs full file path! OutFile = open("/home/nephish/Test.txt", "w") OutFile.write("Here … | |
Re: You might have to rethink your CharSwap() function or you end up with two Seconds, a runtime error. | |
Re: Some venerable operating systems, databases, spreadsheets and wordprocessors were written in C before C++ came along. | |
Re: Enter the fraction as a string and use one of the many string functions like strtok() to parse the string. Numeric strings can then be converted to numbers. | |
Re: There are error-prone programmers and not-so-error-prone programmers. Python owes a lot to C and C++, so let's not be so harsh. | |
Re: Python is a computer language. For most beginners the easiest language to learn and use to write computer programs. Once you are hooked, you can call yourself a programmer, at least a novice programmer, sort of a one finger pianist. | |
Re: The following code is from the msdn library, slightly modified and tested with Dev-C++ [code]// create a list of files in a given directory // http://msdn.microsoft.com/library/en-us/fileio/fs/listing_the_files_in_a_directory.asp // tested with Dev-C++ #define _WIN32_WINNT 0x0501 #include <windows.h> #include <string.h> #include <stdio.h> int main(int argc, char *argv[]) { WIN32_FIND_DATA FindFileData; HANDLE hFind = … | |
Re: This is one simple example ... [php]// find and point to a given character in a string #include <iostream> using namespace std; int main() { char str1[] = "This is just a simple sample string!"; char *pch; cout << "Looking for character s in \"" << str1 << "\"" << … | |
Re: There is a little code snippet here on DaniWeb called "Sending Text to a Printer" [url]http://www.daniweb.com/code/snippet122.html[/url] I don't know much about your compiler, but there maybe some helpfull hints in there. | |
Re: Always an interesting project. This sort of thing is called a "Function Parser" and there is a good C++ discussion at: [url]http://www.students.tut.fi/~warp/FunctionParser/[/url] | |
Re: Look at this code snippet here on DaniWeb: "Play a MIDI voice (Dev C++ console program)" [url]http://www.daniweb.com/code/snippet97.html[/url] This one has a possible volume setting. Experiment with the sound effects best for your project. | |
Re: Is your idea to have Python create an HTML file that you can look at in your browser? | |
Re: Another way to purge all those wobbly '\n' ... [code] // clear the stream, purge any \n while (cin.get() != '\n') ; [/code] Goofy? Yes, these pitfalls make C++ one of the most difficult languages to learn. Kind of job security in the end. | |
Re: Look at the DaniWeb C++ code snippets, there are some examples. | |
Re: There is a hint on how to do this in C code snippet: [url]http://www.daniweb.com/code/snippet6.html[/url] You still have to do the work to modify it to your needs. I hope that's what you had in mind in the first place. | |
Re: You need to let us know what kind of a data file this is. If it is just a text file, you can read the whole thing into a string and go from there ... [code=python]# read the entire text from a file into a string fileHandle = open ( … | |
Re: The function strcmp(string1, string2) compares the two strings, string1 and string2, and returns an integer: < 0 (string1 is less than string2) 0 (string1 is identical to string2) > 0 (string1 is greater than string2) If you try to compare an integer with a string, you get an error! | |
Re: I have to admit that VCS.NET 2003 is a very good product. You used to be able to get it from Amazon.com and other places for around $100. As of right now it's pretty well sold out. So the academic version of the full blown studio sounds like a real … | |
Re: Using C++ for Windows GUI programming is mildly complex. Just look over some of the DaniWeb C++ code snippets and judge for yourself. I can imagine that some of your beginning students would be overwhelmed. | |
Re: If you want to do something even closer to sprintf(), you can use the formatting statement. As Narue pointed out, in Python you must use indentations to group your statements. [code=python] user_name = 'user' for i in range ( 1, 100 ): #user = user_name + str ( i ) … | |
Re: I like C# the best. It has a good flow with GUI programs. C++ is okay, I have a lot of years vested in it's buddy C. VB gives me the willies, it's a bitch to read, the whole project is scattered over a zillion files!!! Candy for the stupid!! | |
Re: You can use the value from time. If you are using Freepascal check [url]http://www.freepascal.org/docs-html/rtl/sysutils/datetimeroutines.html[/url] I would advice you to post your questions in the Pascal Sub-Forum. That's were the experts are. | |
Just want to get ideas on which modern language could replace good old Basic, so the learning curve isn't too galling. I am partial to Python. The reasons: 1. It is an interpreted language, but can be compiled. 2. It has a very efficient memory manager built-in. 3. Lots of … | |
Re: An example in C, sorry but venerable old C was all I could find in a hurry! [PHP]// sort of an array of random integers using shell-sort // an optimized insertion sort developed by Donald Shell // Pelles C #include <stdio.h> #include <stdlib.h> // rand() #define NUM_ITEMS 100 void shellSort(int … | |
Are there any good and free Pascal compilers out there? | |
Re: Here is a little insight into Lisp from a Python programmer. I found it interesting to read ... [url]http://ibiblio.org/obp/py4fun/lisp/lisp.html[/url] | |
Re: Depending on your operating system, use a DOS or Unix call ... [code] // clear the screen in console mode, the dirty way ... #include <cstdlib> int main(void) { // your code system ("cls"); //system ("clear"); // for Unix return(0); } [/code] Be careful with these old DOS commands, it's … | |
Re: Not knowing what operating system you are using, here is some old and ugly Turbo C code. You could leave out the x,y info. It contains the one big hint, that you might as well use assembler ... [code] /************************** m_releas.cf ****************************** ** ** Returns pointers to the coordinate values … | |
Re: I would convert the number to a string using sprintf() then loop through each character in the string and check with isdigit(). If true, then atoi() the character and add it to the sum. An interesting exercise! | |
Re: To get started with programming concepts I would recommend Python. Python borrows a lot from C, C++ and Java, also makes it easy to write and test your programs. Once you feel comfortable with programming, you then should make the transition to the ultimate powerhouse called C++ in my experience. … | |
Re: Download the latest version of Dev-C++ devcpp-4.9.9.2_setup.exe from [url]http://sourceforge.net/projects/dev-cpp/[/url] This is the bloodshed development group, so this compiler is often mistakenly called the Boodshed compiler. Actually what you get is a great IDE using the GNU set of compilers. I like to use it! It's pretty generic. The help file … | |
I am not shamelessly promoting this book, I just happen to like it and use it a lot! "Standard C++ Bible" by Stevens and Walnum, published by Hungry Minds. This 800 page plus book is loaded with samples and comes with a CD-ROM containing all the samples and a nifty … | |
Re: How about a shell-sort, this one has three nested for loops ... [php] // shell sort routine of n items in array[n] void shellsort(int *array, int n) { int basectr, curctr, gapctr, gap, temp; // reduce gap by 1/2 each loop for(gap = n / 2; gap > 0; gap … |
The End.