Posts
 
Reputation
Joined
Last Seen
Ranked #309
Strength to Increase Rep
+8
Strength to Decrease Rep
-2
80% Quality Score
Upvotes Received
51
Posts with Upvotes
45
Upvoting Members
24
Downvotes Received
12
Posts with Downvotes
12
Downvoting Members
7
14 Commented Posts

118 Posted Topics

Member Avatar for happygeek

"...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.

Member Avatar for simhakidsden
9
3K
Member Avatar for gishi

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]

Member Avatar for Gribouillis
0
15K
Member Avatar for vegaseat

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 …

Member Avatar for vegaseat
23
34K
Member Avatar for vegaseat

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]

Member Avatar for vegaseat
20
18K
Member Avatar for The Mad Hatter
Member Avatar for lrh9

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, …

Member Avatar for jamercee
0
6K
Member Avatar for slfisher

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 …

Member Avatar for halenmartinez
1
583
Member Avatar for stevelll

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 …

Member Avatar for tutux
0
172
Member Avatar for hughesadam_87

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...?

Member Avatar for hughesadam_87
0
4K
Member Avatar for ProNewb

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.

Member Avatar for ProNewb
0
176
Member Avatar for Dani

At present the survey requires only a username to participate. Aren't you concerned that someone might vote using other usernames?

Member Avatar for TrustyTony
1
459
Member Avatar for 3e0jUn

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 …

Member Avatar for snippsat
0
484
Member Avatar for lrh9

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 …

Member Avatar for lrh9
0
263
Member Avatar for drichird

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 …

Member Avatar for drichird
0
8K
Member Avatar for abhik1368

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.

Member Avatar for TrustyTony
0
131
Member Avatar for fatalaccidents

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 …

Member Avatar for moroccanplaya
0
363
Member Avatar for inuasha

[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.

Member Avatar for snippsat
0
3K
Member Avatar for WolfShield
Member Avatar for WolfShield
0
243
Member Avatar for lrh9

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 …

Member Avatar for TrustyTony
0
206
Member Avatar for inuasha

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.

Member Avatar for inuasha
0
216
Member Avatar for Luis Ventura

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 …

Member Avatar for Luis Ventura
0
543
Member Avatar for lrh9

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 …

Member Avatar for lrh9
0
1K
Member Avatar for arson09

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.

Member Avatar for arson09
0
224
Member Avatar for M09

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?

Member Avatar for M09
0
549
Member Avatar for Acidz

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 …

Member Avatar for lrh9
0
276
Member Avatar for lionaneesh

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]

Member Avatar for colstonewall
0
413
Member Avatar for TrustyTony

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]

Member Avatar for Stackheuw
2
2K
Member Avatar for Cyph0n

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, …

Member Avatar for lrh9
0
244
Member Avatar for lrh9

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 …

Member Avatar for TrustyTony
0
141
Member Avatar for lrh9

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 …

Member Avatar for lrh9
0
116
Member Avatar for Cesiumlifeboat
Member Avatar for Gribouillis
0
165
Member Avatar for Beat_Slayer

Smart thinking. I might drop back by and add some stuff. I would make a minor gripe. Attributes and methods with two leading underscores and no trailing underscores are mangled by Python. I know your intention is to indicate that these attributes and methods should not be accessed externally, but …

Member Avatar for Beat_Slayer
0
3K
Member Avatar for Shane the House

I like using dictionaries for my multidimensional containers using coordinate tuples as keys. It's not a conventional approach, but despite any disadvantages it has some advantages. For very small or very large coordinates, it has a memory advantage because "coordinates" don't need to exist until they are assigned to. The …

Member Avatar for vegaseat
0
121
Member Avatar for ROTC89

If you can, check out the fractions module. [url]http://docs.python.org/library/fractions.html#module-fractions[/url] The source is included with Python. If you can locate it, you can see how the author(s) did it.

Member Avatar for ROTC89
0
3K
Member Avatar for group256
Member Avatar for Thisisnotanid

Use an online resource that makes it easy to retrieve data. Many sites have an API (Application Programming Interface) that allow programs to retrieve data with a few function calls. For instance, Yahoo lets you retrieve a csv file of stock quotes with a url. You can use the urllib.retrieve …

Member Avatar for Thisisnotanid
0
464
Member Avatar for Stefano Mtangoo

Implement a custom importer in conformance with PEP 302 utilizing code from the "importlib" and "imp" modules. This importer can emulate Python import functionality, or you can alter it to suit your desired behavior. For instance, implement an importer that returns a copy of a module instead of modules stored …

Member Avatar for lrh9
0
6K
Member Avatar for socksy

Have you tried making a client locally and getting it to connect? Maybe the reason select fails to return any sockets is because no one is trying to connect. (Therefore there are no sockets to call accept on.) Maybe you should try making a client instead of a server. You …

Member Avatar for socksy
0
208
Member Avatar for ThePythonNoob

I like to code a simple switch using True or False. When you need to flip the switch then changing state is as easy as: [code=PYTHON]#Switch in the 'off' state state = False #Flip the switch state = not state #Switch is now in the 'on' state #Flip again state …

Member Avatar for lrh9
0
210
Member Avatar for blacknred

Python comes with a csv module you should use to extract the data. Search your documentation for how to write to files. The way you are doing it is totally wrong.

Member Avatar for e-papa
0
182
Member Avatar for e-papa

An object is just an abstraction of data and functions. An object has attributes (data) and methods (functions that interact with its attributes). A class is a blueprint describing the objects created from it. When you write a class you are 'declaring' a class. An object created from a class …

Member Avatar for e-papa
0
359
Member Avatar for Atistus
Member Avatar for Atistus
0
175
Member Avatar for ThePythonNoob

I make my user input loops follow this pattern: [code=PYTHON] #Start a loop that will run indefinitely. while True: i = input("Prompt: ") #Here I do my input checking. In this example it checks that i isn't an empty string. if i: #Break out of the indefinite loop. break[/code]

Member Avatar for bumsfeld
0
171
Member Avatar for bumsfeld

I was looking for a high level language to program a.i. in and after trying AutoHotkey I decided to try Python since it provides standard library support for more processing primitives. (Threading and multiprocessing.)

Member Avatar for vegaseat
1
127
Member Avatar for linux
Member Avatar for richieking
0
5K
Member Avatar for TheSassyDragon

Here's Python 3.x code I wrote for cards and decks. Maybe it will give you some inspiration. [url]http://pastebin.com/wujeXQjV[/url] In most implementations, suits and ranks are simply represented by numbers. I make my implementation only slightly more complex for extra expressiveness. (My suits have symbols and words, and my ranks have …

Member Avatar for lrh9
0
684
Member Avatar for ultimatebuster

You are right that checking is terribly inefficient. Use messaging instead of checking. (When an event happens, make that system send a notification to the systems waiting on it.) There are packages for event systems out there. I can't recommend one, but search and check out the source. You might …

Member Avatar for ultimatebuster
0
155
Member Avatar for WildBamaBoy

The @ symbol is syntax indicating a decorator. In this instance, the decorator takes the function it decorates (a.k.a. wraps) and makes a new function that starts the old function in a new thread. A normal decorator will not preserve the name and docstring of the old function, but @wraps …

Member Avatar for lrh9
0
174
Member Avatar for Tenck

Seems to me like it would be good to use both concurrently. I've all ready written a few scripts that can run with both 2.x and 3.x. Python packages and modules are open source. If you ever want them for a new version you can always refactor the old version. …

Member Avatar for snippsat
0
285
Member Avatar for gunneronaspooky

God I want to smack the creators of some of those courses upside the head with a thick book.

Member Avatar for gunneronaspooky
0
133

The End.