Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: What is wrong with the code?
Post: RE: What is wrong with the code?
(Dec-02-2016, 06:59 PM)metulburr Wrote: you are creating target as a class variable, when you meant to create it as an instance variable.
class A(object):
def __init__(self):
self.targ... |
|
dullboy |
General Coding Help |
3 |
5,866 |
Dec-02-2016, 08:21 PM |
|
|
Thread: What is wrong with the code?
Post: What is wrong with the code?
Here is the code,
class A():
target = open("test.log", "a")
def test(self):
print "test"
target.write("test\n")
target.close()
def main():
a = A()
a.test()
if __nam... |
|
dullboy |
General Coding Help |
3 |
5,866 |
Dec-02-2016, 06:18 PM |
|
|
Thread: Some questions related to tornado httpserver and httpclient
Post: Some questions related to tornado httpserver and h...
Question 1:
tornado.httpserver is a non-blocking http server. Is there any blocking http server?
Question 2:
Does asynchronous always mean non-blocking? Does synchronous always mean blocking?
Than... |
|
dullboy |
Web Scraping & Web Development |
1 |
3,974 |
Nov-17-2016, 06:17 AM |
|
|
Thread: Help with passing value
Post: Help with passing value
Here is my code,
#mycode.py
import click
import json
def read_config(ctx, param, value):
d = json.load(value)
#ctx.default_map = d
def retFunc(ctx, param, value):
return value
@click.grou... |
|
dullboy |
General Coding Help |
1 |
3,429 |
Oct-14-2016, 10:22 AM |
|
|
Thread: Help with click
Post: RE: Help with click
(Oct-11-2016, 12:36 PM)metulburr Wrote: (Oct-11-2016, 12:30 PM)dullboy Wrote: (Oct-10-2016, 06:34 PM)But what is expose_value for? The doc says that the expose_value parameter prevents the prett... |
|
dullboy |
General Coding Help |
12 |
11,165 |
Oct-11-2016, 12:47 PM |
|
|
Thread: Help with click
Post: RE: Help with click
(Oct-10-2016, 06:34 PM)But what is expose_value for? The doc says that the expose_value parameter prevents the pretty pointless parameter from being passed to the callback. What does it mean? Also w... |
|
dullboy |
General Coding Help |
12 |
11,165 |
Oct-11-2016, 12:30 PM |
|
|
Thread: Help with click
Post: RE: Help with click
I am not sure if you really know the answer.
snippsat
Quote:Actually, I did't ask what would be the output of the code. I asked what will be passed to param and value of callback function print_ve... |
|
dullboy |
General Coding Help |
12 |
11,165 |
Oct-10-2016, 04:53 PM |
|
|
Thread: Help with click
Post: RE: Help with click
(Oct-10-2016, 02:57 PM)Actually, I didn\t ask what would be the output of the code. I asked what will be passed to param and value of callback function print_version. snippsat Wrote: # Do not call ... |
|
dullboy |
General Coding Help |
12 |
11,165 |
Oct-10-2016, 04:16 PM |
|
|
Thread: Help with click
Post: RE: Help with click
Thanks for your reply. But I still don't quite understand the tutorial you referenced. Can you walk me through the example in the following?
#test.py
import click
def print_version(ctx, param, value)... |
|
dullboy |
General Coding Help |
12 |
11,165 |
Oct-10-2016, 12:32 AM |
|
|
Thread: Help with click
Post: RE: Help with click
(Oct-09-2016, 08:11 AM)Mekire Wrote: Not familiar with click, but as it says, try adding param to the callback signature.
Line 3 should look like this:
def print_version(ctx, param, value):
Thanks ... |
|
dullboy |
General Coding Help |
12 |
11,165 |
Oct-09-2016, 08:57 AM |
|
|
Thread: Help with click
Post: Help with click
Here is the code,
#test.py
import click
def print_version(ctx, value):
if not value or ctx.resilient_parsing:
return
click.echo('Version 1.0')
ctx.exit()
@click.command()
@click.optio... |
|
dullboy |
General Coding Help |
12 |
11,165 |
Oct-09-2016, 07:54 AM |
|
|
Thread: Is there any way to check if a function is user-defined?
Post: RE: Is there any way to check if a function is use...
Okay, I explain why I asked this question. Basically I want to call settrace to list all the functions executed during the program run. But I want to list only user-defined functions executed during t... |
|
dullboy |
General Coding Help |
11 |
10,244 |
Oct-06-2016, 03:42 AM |
|
|
Thread: Is there any way to check if a function is user-defined?
Post: RE: Is there any way to check if a function is use...
(Oct-05-2016, 03:28 PM)sparkz_alot Wrote: Usually it's pretty straight forward, if I understand your question correctly. If you see something like
def a_function():it will be a user defined function... |
|
dullboy |
General Coding Help |
11 |
10,244 |
Oct-05-2016, 03:32 PM |
|
|
Thread: Is there any way to check if a function is user-defined?
Post: RE: Is there any way to check if a function is use...
(Oct-05-2016, 02:20 PM)metulburr Wrote: Your going to have to be more specific. User defined functions in what?
As long as a function is defined by a user no matter where the function is defined. |
|
dullboy |
General Coding Help |
11 |
10,244 |
Oct-05-2016, 02:44 PM |
|
|
Thread: Is there any way to check if a function is user-defined?
Post: Is there any way to check if a function is user-de...
Sometimes it would be nice to single out the functions defined by users in a big project. So is there any way to differentiate user-defined functions from library functions? Thanks. |
|
dullboy |
General Coding Help |
11 |
10,244 |
Oct-05-2016, 02:14 PM |
|
|
Thread: How to define a global file?
Post: RE: How to define a global file?
(Oct-05-2016, 01:23 PM)Crimson King Wrote: Hey dullboy,
The easiest way would be the one you mentioned, using the trace module from the command line:
python -m trace --trackcalls your-python-progr... |
|
dullboy |
General Coding Help |
11 |
15,906 |
Oct-05-2016, 02:08 PM |
|
|
Thread: How to define a global file?
Post: RE: How to define a global file?
Actually, all I want is to trace the program execution and list the functions executed during the program run. Should I simply use trace module? Thanks. |
|
dullboy |
General Coding Help |
11 |
15,906 |
Oct-05-2016, 05:32 AM |
|
|
Thread: How to define a global file?
Post: How to define a global file?
I need to set up a file as a log file in my python program. So basically I need to create a global file. I am just wondering what is the best way to define a global file in python? Thanks. |
|
dullboy |
General Coding Help |
11 |
15,906 |
Oct-05-2016, 05:10 AM |