python

What is ODBC and how can I take advantage of it (Linux)?

I am creating a master database using SQLite. This single file contains a dozen tables. I want everybody in my group to have access to it (either through Python or through the SQLite command line) and I was thinking of simply putting the file in a group readable directory and calling it 'master.db'. Now, the buzz word 'ODBC' comes to mi...

C++ Structure within itself?

I've been trying to port this code to python, but there is something I do not quite understand in C++ (I do know a bit of C++ but this is beyond me): typedef struct huffnode_s { struct huffnode_s *zero; struct huffnode_s *one; unsigned char val; float freq; } huffnode_t; What I don't get is how huffnode_s can be within...

Python csv reader acting weird

So OK if I run this wrong code: csvReader1 = csv.reader(file('new_categories.csv', "rU"), delimiter=',') for row1 in csvReader1: print row1[0] print row1[8] category_sku = str(row[8]) if category_sku == sku: classifications["Craft"] = row[0] classifications["Theme"] = row[1] I get: Knitting 391...

Which logging library to use for cross-language (Java, C++, Python) system

I have a system where a central Java controller launches analysis processes, which may be written in C++, Java, or Python (mostly they are C++). All these processes currently run on the same server. What are you suggestions to Create a central log to which all processes can write to What if in the future I push some processes to anothe...

Python: When passing variables between methods, is it necessary to assign it a new name?

I'm thinking that the answer is probably 'no' if the program is small and there are a lot of methods, but what about in a larger program? If I am going to be using one variable in multiple methods throughout the program, is it smarter to: Come up with a different phrasing for each method (to eliminate naming conflicts). Use the same nam...

How to get methods list in scala

In language like python and ruby to ask the language what index-related methods its string class supports (which methods’ names contain the word “index”) you can do “”.methods.sort.grep /index/i And in java List results = new ArrayList(); Method[] methods = String.class.getMethods(); for (int i = 0; i < methods.length; i++) { ...

What exactly is a web application framework?

I'm getting into python for cgi and came across Django. I'm not quite sure I understand it very much. Is it something I have to install inside apache or is it just something I can use with my cgi? Wanted to know because I'd love to learn it but my server I'm using doesn't give me a lot of privileges. thanks ...

Scrapy Could not find spider Error

I have been trying to get a simple spider to run with scrapy, but keep getting the error: Could not find spider for domain:stackexchange.com when I run the code with the expression scrapy-ctl.py crawl stackexchange.com. The spider is as follow: from scrapy.spider import BaseSpider from __future__ import absolute_import class StackEx...

Cookies with urllib

This will probably seem like a really simple question, and I am quite confused as to why this is so difficult for me. I would like to write a function that takes three inputs: [url, data, cookies] that will use urllib (not urllib2) to get the contents of the requested url. I figured it'd be simple, so I wrote the following: def fetch(u...

Not able to pass multiple override parameters using nose-testconfig 0.6 plugin in nosetests

Hi, I am able to override multiple config parameters using the nose-testconfig plugin only if I pass the overriding parameters on the command line, e.g. nosetests -c nose.cfg -s --tc=jack.env1:asl --tc=server2.env2:abc But when I define the same thing inside nose.cfg, than only the value for the last parameter is modified. e.g. tc =...

what does 'cgi.parse_qs' mean

i find this code : def _oauth_parse_response(body): p = cgi.parse_qs(body, keep_blank_values=False) but i don't know what is mean thanks ...

problem with random function in python

how can i using random function (in python) to choice a string from a txt list ? thanks a lot ...

any gae framework for facebook user login..

i want to use this framework for facebook user login. thanks ...

successful using twitter login on gae, but how to show user info ..

i use http://github.com/joshthecoder/tweepy-examples to twitter user login on gae, and successful now ,but ,how to show user info ? i have the 'auth' object ,and what is the document about auth method and property, auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) thanks ...

how to import a 'zip' file to my .py ..

when i use http://github.com/joshthecoder/tweepy-examples , i find : import tweepy in the appengine\oauth_example\handlers.py but i can't find a tweepy file or tweepy's 'py' file, except a tweepy.zip file, i don't think this is right,cauz i never import a zip file, i find this in app.py: import sys sys.path.insert(0, 'tweepy.zip...

Python scope problems only when _assigning_ to a variable

So I'm having a very strange error right now. I found where it happens, and here's the simplest code that can reproduce it. def cause_an_error(): some_var = False def some_nested_func(): print some_var #some_var = True some_nested_func() >>> cause_an_error() False If you run it as-is, it prints "False". Bu...

Object-oriented GUI development in python

Hey guys, new programmer here. I have an assignment for class and I'm stuck... What I need to do is a create a GUI that gives someone a basic arithmetic problem in one box, asks the person to answer it, evaluates it, and tells you if you're right or wrong... Basically, what I have is this: class Lesson(Frame): def __init__ (self, ...

Adding custom fields to users in django

I am using the create_user() function that Django provides to create my users. Also I want to store additional information about the users. So I tried following the instructions given at http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users but I cannot get it to work for me. Is there a step-by-s...

Python: How can I override one module in a package with a modified version that lives outside the package?

I would like to update one module in a python package with my own version of the module, with the following conditions: I want my updated module to live outside of the original package (either because I don't have access to the package source, or because I want to keep my local modifications in a separate repo, etc). I want import stat...

Django Barcode for store sales

I am in process of converting Visual Basic app into Python Django. Currently, it has barcode functionality to process sales at a store. Can this be achieved with python django. ...