- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 51
- Posts with Upvotes
- 45
- Upvoting Members
- 24
- Downvotes Received
- 12
- Posts with Downvotes
- 12
- Downvoting Members
- 7
Re: "...head over to the sales websites..." Marketers. Their goal is to sell at any cost, and not to give you the best product for your needs. | |
Re: Don't separate the user id from the entry. [code]import csv, contextlib usernfo = {} with contextlib.closing(open()) as ifile: for entry in csv.DictReader(ifile): usernfo[entry['id']] = entry print(usernfo)[/code] | |
Re: One thing that I'm very glad I learned to do as a beginner and still use today - even though I'm probably still a beginner - is to have a basic file with code that is used more often than not in the script. I can copy this file each … | |
Re: Make an irc bot to connect to an irc server and channel and respond to users in various ways. Download irclib to get some code to start from. [url]http://irclib.bitlbee.org/[/url] If you can, get a copy of IRC Hacks published by O'Reilly. [url]http://www.jibble.org/irchacks/[/url] | |
Re: Dual boot with XP and whatever version of Unix/Linux has my fancy. | |
There is a security technique known as code signing. It basically generates a certificate for your code. This certificate first certifies the author of the code. Second, it has a value generated from the code. This value is unique to that code. If any changes are made to the code, … | |
Re: A picture or multiple pictures are just extremely small slices of a person's life. It doesn't represent the whole of person's life. There will be times when a manic person will be placid, or an agoraphobic person will go out in public. As long as someone is going to an … | |
Re: Task 1 is probably something that could be accomplished using system utilities if you were willing to research the options. I bet you could write a command line script or something to do it. Task 2 can have many approaches. If the program in question supports the right command line … | |
Re: Why do you need to check an object's mutability? Sounds like you need to solve a different problem or use a different solution. Technically you could try to make whatever changes you wanted to make and catch any AttributeError exceptions, but it still seems funny. So...? | |
Re: Builtins are the way to do it, but in your function you reset s to zero each loop because it is inside the loop. It needs to be set to zero before the loop. | |
Re: At present the survey requires only a username to participate. Aren't you concerned that someone might vote using other usernames? | |
Re: It depends on the structure of your file and what you are trying to do. To update (read and write) a file you usually open it with mode r+. From your other posts, I can see you are making a game. Are you trying to develop a save system or … | |
I had been wanting to write an IRC bot with asynchronous IO for a while. My bot responds to pings, but can be extended by defining functions and registering them to get called when the bot receives certain commands. My bot uses the RFC 1459 USER command and parameters, but … | |
Re: You can write a module that can also act as a script by using the idiom: if __name__ == '__main__': pass Importing a module and then executing the main body of that module is indicative of a design problem, but can be accomplished by wrapping the main body in a … | |
Re: The Python standard library features a csv module for CSV file reading and writing. Read the module documentation to learn how to use it. I'd use a dictionary or collections.OrderedDict to associate each unique key with a list of values. | |
Re: I think that if someone takes the time to get an abstract overview of programming languages, he or she finds that programming languages are relatively simple and those featuring the same [URL="http://en.wikipedia.org/wiki/Programming_paradigm"]programming paradigms[/URL] are quite similar. It's a fascinating subject. When a person studies a specific programming language, he or … | |
Re: [url]http://en.wikipedia.org/wiki/Pseudorandom_number_generator[/url] There is even a link to an algorithm with a psuedocode implementation. Personally, I think you should find something else to work on. I think reimplementing established algorithms will provide little educational value. | |
Re: [url]http://en.wikipedia.org/wiki/There's_more_than_one_way_to_do_it[/url] | |
I am doing some hobby coding regarding neural networks, and I was wondering if this is a correct and good use of abstract base classes or not. [code=PYTHON]import abc import collections import math import weakref class AbstractNeuron(metaclass=abc.ABCMeta): def __init__(self, weights, f=math.tanh, bias=1, biasWeight=0): self.weights = weights self.f = f self.bias … | |
Re: I've never used it, but the subprocess module may be what you need. It seems to feature a function that will start a subprocess and wait for the subprocess exit code. If the exit code is non-zero then the function will raise an exception. | |
Re: Sounds like an application for collections.Counter. First do the Python tutorial to learn the Python language. [url]http://docs.python.org/py3k/tutorial/index.html[/url] Then review the library reference to get an overview of Python's built in functionality. [url]http://docs.python.org/py3k/library/index.html[/url] Finally, read the documentation for collections and try to write your program. [url]http://docs.python.org/py3k/library/collections.html[/url] We can't help you if … | |
Hand evaluator for Texas Hold'em. If a "hand" has five or more cards, hand.rank will find the best five card hand the hand can form. Two hands can be compared using the comparison operators. The final hand can be gotten from the "hand" with hand.rank.hand. The value used for comparisons … | |
Re: Is this for production or is it just an exercise? If it is for production use bisect.insort to insert items into a list in sorted order. | |
Re: Seems like the big barrier here is that the poster's primary language must not be English. I tried searching for "moy", but I didn't get any promising results. Perhaps it is an abbreviation or truncation? | |
Re: As a designer and coder we should be as abstract as usefully possible. Abstract software is compact and reusable. You are treating classes as namespaces and making a specific class or function for every thing. You should treat classes as blueprints that abstractly specify the attributes and capabilities of a … | |
Re: Anyone with sufficient skills at Google could have found that information in the Python documentation. [url]http://www.lmgtfy.com/?q=python+dictionary[/url] [url]http://docs.python.org/tutorial/datastructures.html#dictionaries[/url] | |
Re: It's also possible to bin items to a collection like a set or list. This technique can bin items without key collisions. [code=PYTHON]import collections data = ((5.639792, 1.36), (4.844813, 1.89), (4.809105, 2.33), (3.954150, 2.69), (2.924234, 3.42), (1.532669, 4.50), (0.000000, 5.63)) bucket = collections.defaultdict(list) for each in data: bucket[int((each[1]))].append(each[0]) print(bucket) [/code] | |
Re: It's not unusual for early implementations of code to be excessive or unrefined. The important thing is to refactor as necessary. [url]http://en.wikipedia.org/wiki/Code_refactoring[/url] Your early implementations and final versions will improve over time if you learn more about Python, plan what you want your code to do, decompose data and functions, … | |
I'm working on a project where I would like to compare collections of words, but I have additional constraints I need to account for. The collections are like a set in that order doesn't matter for the comparison. However, in my problem equal elements are significant. E.g. the collection of … | |
I'm interested in a generic event system for Python. I've searched the forum for similar topics, and I've searched the web for existing implementations. I haven't found exactly what I'm looking for. I'm familiar with the Observer pattern. However, my implementation and other implementations lack strong support for concurrency and … |