939 Posted Topics
Re: If I google my real name pictures of nude women come up at the top (I think it's pinup or something). | |
Re: "YES" is not the same as "yes". To rectify, convert the input to lower case. Something like: [code=python] ans=raw_input("Are you feeling well today? ") if ans.lower() == "yes": print "That's good" else: print "Too bad" [/code] | |
Re: [url]http://docs.python.org/library/copy.html[/url] You're welcome. | |
Re: One of the best nuggets of wisdom I ever got about using Ubuntu (and other Debian based systems) is learn to use apt. I suppose it applies to whatever package manager that your distribution happens to be using. Here's a quick run down on how I use apt. 1. Find … | |
Re: i am not racist or sexist anway. I thought most muslim people were. | |
Re: you almost had it: [code="python"] x = [5, 3, 7] x = x.sort() # or x.sorted() print x [/code] | |
| |
Re: The problem is that you denied IDLE the right to create a loopback server (which it needs; it doens't actually connect to the internet). You need to create an exception in your firewall that allows python to act as a server. You can google search on how to configure your … | |
Re: Python makes this sort of thing easy. [code="python"] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" keyword = raw_input().upper() # You may want to check that the keyword contains only letters from A-Z # if not keyword.isalpha(): # do something for letter in keyword: # remove keyword letters from alphabet alphabet = alphabet.replace(letter, "") d … | |
Re: [QUOTE=serkan sendur;854123]he is at your father's age, that is natural that he knows a lot.[/QUOTE] No. That would suggest that the older you are, the more you know, which is just not true. Case in point: you're older than I am. | |
Re: What error are you receiving? Is it apache or IIS (don't know if this matters, but / works on my apache in windows). Does the snaps directory already exist? Because you might get an error (Permission Denied.) if it doesn't. Hope this helps. | |
Re: you can try [code=python] mtrx = [[(0,0) for i in range(n)] for i in range(n)] [/code] Where n is the size of the matrix on both dimensions. | |
Re: Somebody should make a sticky thread titled "Can python do this?" with a single one-word post that reads: "Yes." | |
Re: [QUOTE=thoughtcoder;856577]You obviously have trouble understanding what I'm saying. I'm saying that your worldview (with your insane notion of "intellectual property") is wrong.[/QUOTE] But what if your worldview (with your [insane?] notion of universal freedom) is wrong instead? Point? You can't really tell someone that their world-view is "wrong". It can't … | |
Re: This is a truly puzzling problem. Perhaps you'd like to attach your coinflip.py script? EDIT; The script in vegaseat's very last post works fine for me on python 2.6. Maybe your python installation is incorrectly configured, or...? EDIT 2: Having read you last post I went back and revised. I … | |
Re: you can do something like: [code=python] big_string = "" while not big_string.endswith("hth"): big_string += flip() flips = len(big_string) [/code] By find command I assume you mean find an occurence of a substring withing a string? Yes, just do [icode]s.find(sub, start, end)[/icode] where s is the string, and sub is the … | |
Re: Doesn't [icode]spriteObj = sprite_class.Sprite()[/icode] work? | |
Re: On line 22 you have the incorrect format string for the argument b. The format string should be [icode]"(O)"[/icode] as the argument is a Python object and not a null terminated wchar_t buffer. However, it seems that all you are trying to do is get a wchar_t buffer from the … | |
Re: The basic algorithm I would use to start with goes something like this. As the code gets more mature I would look to refine and optimize it. [code] Loop through each pixel in the image: if the pixel's calculated luminance is more than a set constant: record pixel's location if … | |
Re: QT (pyQT) can do svg files, I believe. Cairo (pyCairo) can also. The former is a GUI framework will the latter is a graphics library. EDIT: nevermind; I don't think QT can save svg files. I know cairo can render to pdf [B]and[/B] svg files though. | |
Re: This is python; of course it's possible! Here's how to retrieve a function (and call it) from a module object. [code=python] # This example imports the 'os' module, tries to retrieve the function 'getcwd' and then calls it. import os func = getattr(os, 'getcwd', False) #Tries to get the attribute … | |
Re: Do you mean you want a copy of the list, instead of the original? [code=python] o = r[:] [/code] Somehow I don't think that's what you mean though. | |
Re: Sigh. This question has been asked and answered loads of times. But if you must. 1. Applications made by both have reasonably native appearances 2. I find them both around the same level of difficultly, but... 3. ...Qt has better documentation 4. That depends 5. Both have LGPL licenses, though … | |
Re: The question for me is more of when [B]not[/B]. I tend to use other languages only when they make sense and then python for everything else (because of all of the ones I know it's the one I enjoy the most): C# for WPF Gui apps, C++ for speed critical … ![]() | |
Re: I think you'd be better off finding out how native apps print on Mac OS X. I know Mac OS X uses CUPS, and I know it supposedly uses a server architecture, but that's about it. | |
Re: You're using python 3.0. print is no longer a statement, but a function, so you have to use print("ok"). I suggest you do some research on how py3k is different from python 2x before you attempt to use it. | |
Re: Do you mean like: [code=python] import random def sample(items, amount): if amount > len(items): raise ValueError("Amount incorrect") r = set() while len(r) < amount: set.add(random.choice(items)) [/code] ? Not the most efficient algorithm, I admit, but it might just be the simplest. EDIT: I misinterpreted you. You need to express yourself … | |
Re: convert one of them to a float first. Something like: m = float(y) / x | |
Re: py2exe can package into a single file. You just have to tell it to. In your setup.py's setup function, adjust your options argument to include the following: [code=python] options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}} [/code] I also noticed that I have [icode]zipfile=None[/icode] as an argument … | |
![]() | Re: Another way is to add C:\Python30 (since you don't have Python 2.6) and C:\Python30\Tools\Scripts to your PATH variable. [URL="http://www.brightrev.com/how-to/windows/35-add-a-utilities-directory-to-your-pc.html?start=1"]http://www.brightrev.com/how-to/windows/35-add-a-utilities-directory-to-your-pc.html?start=1[/URL] Be careful because if you mess it up some programs may stop working. ![]() |
Re: The reason it's printing None is that you're not returning anything from the function. By using print on compare(), you're asking print to print whatever compare returns. compare returns nothing, hence it prints None. To get syntax coloring, change your start code tag to [code=python] | |
Re: You should also know that python has a powerful (though somewhat cumbersome) ctypes library that allows you to call C functions. This will handle your last request if you don't find a different built-in method of doing it (you may have to call the underlying platform's libraries to get the … | |
Re: I don't know how efficient that would be, especially for a large list. The in operator in this context basically loops through the sequence until it finds a match, returning false if it doesn't. The problem I have with its use in the above code is that it can be … | |
Re: Traditionally, options beginning with -- are commands and do require arguments. are you able to use -listContents or /listContents instead? | |
Re: If you use a library like PIL or pygame, you can pass that data to the library and let it handle to compression and saving for you. Just a thought. | |
Re: [code=python] class StopWatch(object): def start(self): #code that starts def stop(self): #code that stops [/code] Can't give any more help than that without a better description of your problem. | |
Re: Now to the difference between for and while. while loops test a condition and execute the body as long as that condition is True. Normally, within the body of the while loop you would have to modify some variables to make the condition false eventually (in this case, you may … | |
Re: replace [icode]print i[/icode] with [icode]print "*" * i[/icode]. You may need to initialize i to 1 instead of 0. EDIT: Actually, that's the easy way out. The other way which might be the one your tutor is looking for (since this seems like homework) is to create another loop inside … | |
Re: What the hell? This is basic math. You fail. | |
Re: take the initializers and put them inside the function body, so that you have: [code=python] def sum(n): i = 0 total = 0 ...rest of your code starting with while statement [/code] Although, I have to ask, what is the purpose of this function? As it is, it will always … | |
Re: You can do fh.read().split(',') to split the line into a list of ['name', 'address', 'phone'] Python also has a [URL="http://docs.python.org/library/csv.html"]built-in csv module[/URL]. As to the code tags, you want to change the first one to [ code=python ]: leave the second one as is. | |
Re: For Windows, you may need to run the script in service space. Services are initialized once windows boots up and run until it shuts down. I don't know how you can run a python script as a service though, you can try bootstrapping. | |
![]() | Re: First of all, you could get some better organization by using functions. Here's a structure I would find easy to work with: get_name() #Gets and returns the first and last name, validating them first get_hours() #Gets and returns the hours worked for the week, with validation get_wage() #Get and return … ![]() |
Re: Well xml files [B]are[/B] text files so yes you can do open() and read just as you normally would a text file. | |
Re: Just a correction to the first response: raw_input() is now input() for Python 3.0. You can put input() at the very end of your scripts if you are running them without IDLE (although I recommend IDLE for beginners) and it will wait until you press ENTER before exiting. | |
Re: Tried the [URL="http://docs.python.org/library/subprocess.html"]subprocess[/URL] module? Try the call() function. | |
Re: Also on windows, doing a "repair" in the control panel Add/remove programs on the version you want will set it as the default. | |
Re: Worth noting: This was "fixed" in Python 3; 5/10 now gives 0.5 |
The End.