text stringlengths 200 200k | source stringclasses 2
values |
|---|---|
# Display number with leading zeros
## Question
Given:
a = 1
b = 10
c = 100
I want to display a leading zero for all numbers with less than 2 digits, i.e.:
01
10
100
## Answer
width = 5
num = 3
formatted = (width - len(str(num))) * "0" + str(num)
print formatted
Tags: python, string-formatting | stackoverflow-qa |
# Display number with leading zeros
## Question
Given:
a = 1
b = 10
c = 100
I want to display a leading zero for all numbers with less than 2 digits, i.e.:
01
10
100
## Answer
Or another solution.
"{:0>2}".format(number)
Tags: python, string-formatting | stackoverflow-qa |
# Python Library Path
## Question
In ruby the library path is provided in $:, in perl it's in @INC - how do you get the list of paths that Python searches for modules when you do an import?
## Answer
import sys
sys.path
Tags: python | stackoverflow-qa |
# Python Library Path
## Question
In ruby the library path is provided in $:, in perl it's in @INC - how do you get the list of paths that Python searches for modules when you do an import?
## Answer
I think you're looking for sys.path
import sys
print (sys.path)
Tags: python | stackoverflow-qa |
# Python Library Path
## Question
In ruby the library path is provided in $:, in perl it's in @INC - how do you get the list of paths that Python searches for modules when you do an import?
## Answer
You can also make additions to this path with the PYTHONPATH environment variable at runtime, in addition to:
import ... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
xrange() is more efficient because instead of generating a list of objects, it just generates one object at a time. Instead of 100 integers, and all of their overhead, and the list to put them in, you just have one integer at a tim... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
You should favour range() over xrange() only when you need an actual list. For instance, when you want to modify the list returned by range(), or when you wish to slice it. For iteration or even just normal indexing, xrange() will ... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
Go with range for these reasons:
1) xrange will be going away in newer Python versions. This gives you easy future compatibility.
2) range will take on the efficiencies associated with xrange.
Tags: python, range, xrange | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
For performance, especially when you're iterating over a large range, xrange() is usually better. However, there are still a few cases why you might prefer range():
In python 3, range() does what xrange() used to do and xrange()... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
range() returns a list, xrange() returns an xrange object.
xrange() is a bit faster, and a bit more memory efficient. But the gain is not very large.
The extra memory used by a list is of course not just wasted, lists have more f... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
Okay, everyone here as a different opinion as to the tradeoffs and advantages of xrange versus range. They're mostly correct, xrange is an iterator, and range fleshes out and creates an actual list. For the majority of cases, you... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
No, they both have their uses:
Use xrange() when iterating, as it saves memory. Say:
for x in xrange(1, one_zillion):
rather than:
for x in range(1, one_zillion):
On the other hand, use range() if you actually want a list o... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
I would just like to say that it REALLY isn't that difficult to get an xrange object with slice and indexing functionality. I have written some code that works pretty dang well and is just as fast as xrange for when it counts (ite... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
One other difference is that xrange() can't support numbers bigger than C ints, so if you want to have a range using python's built in large number support, you have to use range().
Python 2.7.3 (default, Jul 13 2012, 22:29:01) ... | stackoverflow-qa |
# Should you always favor xrange() over range()?
## Question
Why or why not?
## Answer
A good example given in book: Practical Python By Magnus Lie Hetland
>>> zip(range(5), xrange(100000000))
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
I wouldnât recommend using range instead of xrange in the preceding exampleâ... | stackoverflow-qa |
# Reading 32bit Packed Binary Data On 64bit System
## Question
I'm attempting to write a Python C extension that reads packed binary data (it is stored as structs of structs) and then parses it out into Python objects. Everything works as expected on a 32 bit machine (the binary files are always written on 32bit arc... | stackoverflow-qa |
# Reading 32bit Packed Binary Data On 64bit System
## Question
I'm attempting to write a Python C extension that reads packed binary data (it is stored as structs of structs) and then parses it out into Python objects. Everything works as expected on a 32 bit machine (the binary files are always written on 32bit arc... | stackoverflow-qa |
# Reading 32bit Packed Binary Data On 64bit System
## Question
I'm attempting to write a Python C extension that reads packed binary data (it is stored as structs of structs) and then parses it out into Python objects. Everything works as expected on a 32 bit machine (the binary files are always written on 32bit arc... | stackoverflow-qa |
# Reading 32bit Packed Binary Data On 64bit System
## Question
I'm attempting to write a Python C extension that reads packed binary data (it is stored as structs of structs) and then parses it out into Python objects. Everything works as expected on a 32 bit machine (the binary files are always written on 32bit arc... | stackoverflow-qa |
# How can I closely achieve ?: from C++/C# in Python?
## Question
In C# I could easily write the following:
string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?
## Answer
In Python 2.5, t... | stackoverflow-qa |
# How can I closely achieve ?: from C++/C# in Python?
## Question
In C# I could easily write the following:
string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?
## Answer
It's never a bad... | stackoverflow-qa |
# How can I closely achieve ?: from C++/C# in Python?
## Question
In C# I could easily write the following:
string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?
## Answer
@Dan
if otherS... | stackoverflow-qa |
# How can I closely achieve ?: from C++/C# in Python?
## Question
In C# I could easily write the following:
string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?
## Answer
There are a few ... | stackoverflow-qa |
# How many bytes per element are there in a Python list (tuple)?
## Question
For example, how much memory is required to store a list of one million (32-bit) integers?
alist = range(1000000) # or list(range(1000000)) in Python 3.0
## Answer
"It depends." Python allocates space for lists in such a way as to achieve ... | stackoverflow-qa |
# How many bytes per element are there in a Python list (tuple)?
## Question
For example, how much memory is required to store a list of one million (32-bit) integers?
alist = range(1000000) # or list(range(1000000)) in Python 3.0
## Answer
This is implementation specific, I'm pretty sure. Certainly it depends on th... | stackoverflow-qa |
# How many bytes per element are there in a Python list (tuple)?
## Question
For example, how much memory is required to store a list of one million (32-bit) integers?
alist = range(1000000) # or list(range(1000000)) in Python 3.0
## Answer
Useful links:
How to get memory size/usage of python object
Memory sizes o... | stackoverflow-qa |
# How many bytes per element are there in a Python list (tuple)?
## Question
For example, how much memory is required to store a list of one million (32-bit) integers?
alist = range(1000000) # or list(range(1000000)) in Python 3.0
## Answer
Addressing "tuple" part of the question
Declaration of CPython's PyTuple in... | stackoverflow-qa |
# How many bytes per element are there in a Python list (tuple)?
## Question
For example, how much memory is required to store a list of one million (32-bit) integers?
alist = range(1000000) # or list(range(1000000)) in Python 3.0
## Answer
A new function, getsizeof(), takes a
Python object and returns the amount
... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
CTypes is very cool and much easier than SWI... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
SWIG generates (rather ugly) C or C++ code. ... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
You can also use Pyrex, which can act as glu... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
ctypes is great, but does not handle C++ cla... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
I'm going to be contrarian and suggest that,... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
In my experience, ctypes does have a big dis... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
I have a rich experience of using swig. SWIG... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
Something to keep in mind is that SWIG targe... | stackoverflow-qa |
# Python: SWIG vs ctypes
## Question
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
## Answer
Just wanted to add a few more considerations... | stackoverflow-qa |
# Python web development - with or without a framework
## Question
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi... | stackoverflow-qa |
# Python web development - with or without a framework
## Question
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi... | stackoverflow-qa |
# Python web development - with or without a framework
## Question
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi... | stackoverflow-qa |
# Python web development - with or without a framework
## Question
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi... | stackoverflow-qa |
# Python web development - with or without a framework
## Question
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi... | stackoverflow-qa |
# Python web development - with or without a framework
## Question
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi... | stackoverflow-qa |
# Python web development - with or without a framework
## Question
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
A staticmethod is a method that knows nothing about the class or instance it was called on. It just gets the argu... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
Basically @classmethod makes a method whose first argument is the class it's called from (rather than the class i... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
@staticmethod just disables the default function as method descriptor. classmethod wraps your function in a cont... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
Here is a short article on this question
@staticmethod function is nothing more than a function defined insid... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
Maybe a bit of example code will help: Notice the difference in the call signatures of foo, class_foo and static_... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
Official python docs:
@classmethod
A class method receives the class as
implicit first argument, just like... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
I just wanted to add that the @decorators were added in python 2.4.
If you're using python < 2.4 you can use the... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
What is the difference between @staticmethod and @classmethod in Python?
You may have seen Python code like thi... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
I think a better question is "When would you use @classmethod vs @staticmethod?"
@classmethod allows you easy ac... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
Here is one good link for this topic, and summary it as following.
@staticmethod function is nothing more than a... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
@classmethod means: when this method is called, we pass the class as the first argument instead of the instance o... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
To decide whether to use @staticmethod or @classmethod you have to look inside your method. If your method access... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
In Python, a classmethod receives a class as the implicit first argument. The class of the object instance is imp... | stackoverflow-qa |
# What is the difference between @staticmethod and @classmethod in Python?
## Question
What is the difference between a function decorated with @staticmethod and one decorated with @classmethod?
## Answer
Another consideration with respect to staticmethod vs classmethod comes up with inheritance. Say you have the fo... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# Get last n lines of a file with Python, similar to tail
## Question
I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom.
So I need a tail() method that can read n lines from th... | stackoverflow-qa |
# How do you manage your custom modules?
## Question
I write tons of python scripts, and I find myself reusing lots code that I've written for other projects. My solution has been to make sure the code is separated into logical modules/packages (this one's a given). I then make them setuptools-aware and publish them o... | stackoverflow-qa |
# How do you manage your custom modules?
## Question
I write tons of python scripts, and I find myself reusing lots code that I've written for other projects. My solution has been to make sure the code is separated into logical modules/packages (this one's a given). I then make them setuptools-aware and publish them o... | stackoverflow-qa |
# Key Presses in Python
## Question
Is it possible to make it appear to a system that a key was pressed, for example I need to make A key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python.... | stackoverflow-qa |
# Key Presses in Python
## Question
Is it possible to make it appear to a system that a key was pressed, for example I need to make A key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python.... | stackoverflow-qa |
# Key Presses in Python
## Question
Is it possible to make it appear to a system that a key was pressed, for example I need to make A key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python.... | stackoverflow-qa |
# Python language API
## Question
I'm starting with Python coming from java.
I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it.
I've found very helpul to use help( thing ) from the Python ( command line )
I have found this als... | stackoverflow-qa |
# Python language API
## Question
I'm starting with Python coming from java.
I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it.
I've found very helpul to use help( thing ) from the Python ( command line )
I have found this als... | stackoverflow-qa |
# Python language API
## Question
I'm starting with Python coming from java.
I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it.
I've found very helpul to use help( thing ) from the Python ( command line )
I have found this als... | stackoverflow-qa |
# Python language API
## Question
I'm starting with Python coming from java.
I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it.
I've found very helpul to use help( thing ) from the Python ( command line )
I have found this als... | stackoverflow-qa |
# Python language API
## Question
I'm starting with Python coming from java.
I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it.
I've found very helpul to use help( thing ) from the Python ( command line )
I have found this als... | stackoverflow-qa |
# Python language API
## Question
I'm starting with Python coming from java.
I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it.
I've found very helpul to use help( thing ) from the Python ( command line )
I have found this als... | stackoverflow-qa |
# How do you make Python / PostgreSQL faster?
## Question
Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the co... | stackoverflow-qa |
# How do you make Python / PostgreSQL faster?
## Question
Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the co... | stackoverflow-qa |
# How do you make Python / PostgreSQL faster?
## Question
Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the co... | stackoverflow-qa |
# How do you make Python / PostgreSQL faster?
## Question
Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the co... | stackoverflow-qa |
# How do you make Python / PostgreSQL faster?
## Question
Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the co... | stackoverflow-qa |
# How can I perform a HEAD request with the mechanize library?
## Question
I know how to do a HEAD request with httplib, but I have to use mechanize for this site.
Essentially, what I need to do is grab a value from the header (filename) without actually downloading the file.
Any suggestions how I could accomplish ... | stackoverflow-qa |
# Get Bound Event Handler in Tkinter
## Question
After a bind a method to an event of a Tkinter element is there a way to get the method back?
>>> root = Tkinter.Tk()
>>> frame = Tkinter.Frame(root, width=100, height=100)
>>> frame.bind('<Button-1>', lambda e: pprint('Click')) # function needed
>>> frame.pack()
>>> b... | stackoverflow-qa |
# Get Bound Event Handler in Tkinter
## Question
After a bind a method to an event of a Tkinter element is there a way to get the method back?
>>> root = Tkinter.Tk()
>>> frame = Tkinter.Frame(root, width=100, height=100)
>>> frame.bind('<Button-1>', lambda e: pprint('Click')) # function needed
>>> frame.pack()
>>> b... | stackoverflow-qa |
# Is there something like Python's getattr() in C#?
## Question
Is there something like Python's getattr() in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.
## Answer
Use reflection for this.
Type.GetProperty() and Type.GetProperties() each return Pro... | stackoverflow-qa |
# Is there something like Python's getattr() in C#?
## Question
Is there something like Python's getattr() in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.
## Answer
Yes, you can do this...
typeof(YourObjectType).GetProperty("PropertyName").GetValue(... | stackoverflow-qa |
# Is there something like Python's getattr() in C#?
## Question
Is there something like Python's getattr() in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.
## Answer
There is also Type.InvokeMember.
public static class ReflectionExt
{
public stat... | stackoverflow-qa |
# How can I read the RGB value of a given pixel in Python?
## Question
If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel?
Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value?
It would b... | stackoverflow-qa |
# How can I read the RGB value of a given pixel in Python?
## Question
If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel?
Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value?
It would b... | stackoverflow-qa |
# How can I read the RGB value of a given pixel in Python?
## Question
If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel?
Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value?
It would b... | stackoverflow-qa |
# How can I read the RGB value of a given pixel in Python?
## Question
If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel?
Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value?
It would b... | stackoverflow-qa |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.