Karsten Wutzke kwutzke at web.de writes:
So, what is the de facto method in Python to handle source code generation?
Take a look at the NodeVisitor class in the ast module in python 2.6+.
The visitor pattern is implemented in the python standard library.
Matt
--
Josh English joshua.r.english at gmail.com writes:
I have a script that generates a report from a bunch of data I've been
collecting for the past year. I ran the script, successfully, for
several weeks on test runs and creating more detailed reports.
Today (back from vacation) and the
Sneaky Wombat joe.hrbek at gmail.com writes:
Why is python turning \x0a into a \n ?
In [120]: h='\x0a\xa8\x19\x0b'
In [121]: h
Out[121]: '\n\xa8\x19\x0b'
I don't want this to happen, can I prevent it?
'h' is an ascii string. The ascii encoding for '\n' is the number(byte) 0x0A.
I've tried the following workaround, but it often gives me inaccurate
results (due to integer division), so I had to add a safety check:
num_frames = 32
values = [0, 1, 2, 3, 4]
offset_step = num_frames / len(values)
for index in xrange(0, num_frames):
offset = index /
ValueError('malformed string')
return list(map(_convert, node.elts))
Matt McCredie
--
http://mail.python.org/mailman/listinfo/python-list
hong zhang henryzhang62 at yahoo.com writes:
List,
Python does not have switch statement. Any other option does similar work?
Thanks for help.
--henry
I see a couple of people have mentioned using a dictionary. If the value that
you are switching on is a string, or could be
iu2 israelu at elbit.co.il writes:
Hi,
Having a file called funcs.py, I would like to read it into a string,
and then import from that string.
That is instead of importing from the fie system, I wonder if it's
possible to eval the text in the string and treat it as a module.
For
Rhodri James rhodri at wildebst.demon.co.uk writes:
On Fri, 23 Oct 2009 17:39:40 +0100, Matt McCredie mccredie at gmail.com
wrote:
joao abrantes senhor.abrantes at gmail.com writes:
Hey. I want to make a program like this:print Complete the function
f(x)=then the user would
:+statement in {}
print f(2)
print f(4)
print f(6)
Matt McCredie
--
http://mail.python.org/mailman/listinfo/python-list
literal written inside of a python script and a string read from a
file. When reading from a file (or the registry) what you see is what you get.
There is no need to do so much work.
Matt McCredie
--
http://mail.python.org/mailman/listinfo/python-list
New submission from Matt McCredie [EMAIL PROTECTED]:
The following session demonstrates the issue:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on
win32
Type help, copyright, credits or license for more information.
exec def foo():\nreturn 0 # no ending
On Nov 15, 2007 2:15 PM, linda. s [EMAIL PROTECTED] wrote:
On 11/15/07, Matimus [EMAIL PROTECTED] wrote:
On Nov 15, 12:45 pm, linda.s [EMAIL PROTECTED] wrote:
I run the following code and got the error (I put a .gif file on the
desktop)
Traceback (most recent call last):
File
Thanks a lot for your patience.
I put the gif file to a folder called fig in my desktop.
dirpath = './fig'
still got error:
Traceback (most recent call last):
File 11.py, line 238, in module
img.config(image=gifsdict[imgname])
NameError: name 'imgname' is not defined
You should
On 11/2/07, matthias [EMAIL PROTECTED] wrote:
Howdy !
I started using the assert() stmt and found it quite useful :-) I
have only one problem: I don't
know how to turn them off again.
I know that -O turns off assertions in general. However, how do I
pass thus parameter to
python to an
It would be great if I could make a number that can go beyond current
size limitations. Is there any sort of external library that can have
infinitely huge numbers? Way way way way beyond say 5x10^350 or
whatever it is?
I'm hitting that inf boundary rather fast and I can't seem to work
I've got an application running on linux which writes log files using the
python logging module. I'm looking for some help and advice to cap the size
which the file will grow too, something reasonably like 2Mb would be great.
What is the best way to handle this kind of thing? Can this be
En Fri, 19 Oct 2007 21:26:22 -0300, Matimus [EMAIL PROTECTED] escribió:
The common pattern:
if __name__ == __main__:
# do stuff
IMHO better written:
if __main__ == __name__:
# do stuff
I'm intrigued why do you feel the second alternative is better.
Which is your native
On 10/15/07, Dmitri O.Kondratiev [EMAIL PROTECTED] wrote:
To clarify my point:
reverse() is a lucky one - Python has variants of *this particular*
function both for lists and strings. Yet what about other list functions?
How in general, can I write a function that works both on list and
On 10/12/07, Evjen Halverson [EMAIL PROTECTED] wrote:
I have tried to make a Tkinter program make a rectangle move down the
window, but did not succeed. All it does is make a rectangle trail.
What am I doing wrong?
from Tkinter import*
root = Tk()
RectangleColor='orange'
Yes, Digital Mars D is what I was referring to and yes I know D is not
as efficient as C++. If I knew of a good C++ compiler that is not
from Microsoft that works natively with Windows I would be happy to
consider using it.
I've had good luck with MinGW (gcc compiled for windows).
Now I think I will code this little scrambler using nothing but the D
Language just to see whether there is any benefit in using D over
Python for this sort of problem.
Isn't D compiled to machine code? I would expect it to win hands down.
That is, unless it is horribly unoptimized.
Matt
--
It would be nice if Python could be made to automatically detect the
LC and string translation patterns used by the unoptimized Python code
and make them into optimized Python code on the fly at runtime. I am
more than a little amazed nobody has chosen to build a JIT (Just In-
Time compiler)
On 9/19/07, Dan Bar Dov [EMAIL PROTECTED] wrote:
I'm trying to construct a regular expression to match valid IP address,
without leading zeroes (i.e
1.2.3.4, 254.10.0.0, but not 324.1.1.1, nor 010.10.10.1)
This is what I come up with, and it does not work.
On 9/20/07, Ricardo Aráoz [EMAIL PROTECTED] wrote:
Dan Bar Dov wrote:
I'm trying to construct a regular expression to match valid IP address,
without leading zeroes (i.e
1.2.3.4 http://1.2.3.4, 254.10.0.0 http://254.10.0.0, but not
324.1.1.1, nor 010.10.10.1 http://010.10.10.1)
This
On 9/20/07, Python Maniac [EMAIL PROTECTED] wrote:
I am new to Python however I would like some feedback from those who
know more about Python than I do at this time.
Well, you could save some time by not applying the scramble one line
at a time (that is if you don't mind losing the line
On 9/18/07, Thomas Harding [EMAIL PROTECTED] wrote:
Hi guys, sorry to post another topic on this, as I am aware that it has
already been posted a few times, but not with specifically what I am looking
for. I want an app that makes a gui interface for python (similar to
Microsoft visual studio
I am trying to extend list class to build a stack class -- see code below---
but I got an error when I try to call len method from list class here.. why?
Thanks in advance!
Jeff did a good job of answering your questions. I just wanted to note
that your pop is broken, but that doesn't matter
Is Maya a different python build than what is contained at python.org?
If so, I suggest you get your C program to work with the latest python
build
from python.org. Then see if you can get it to work with the Maya
version.
Ok, did that. If I write a normal C++ program and use the
So what exactly is a complex number?
It is a math construct, and has almost nothing to do with Python,
other than the fact that Python has a data type for them.
So, here is a list of better ways to get information about complex
numbers than asking python-list:
1. Google it:
For some odd reason the del array[ray] isn't actually deleting the array
item in the list I get the following output:
C:\Documents and
Settings\program\Desktop\python\pygameremix.py
[2, 2, 2, 4, 4, 4, 4, 3, 3, 3, 3]
[2, 2, 2, 4, 4, 4, 4, 3, 3, 3, 3]
[2, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3]
[2,
Image.open(C:\test.jpg) # this is what I have right now. And it can't
find the file or directory. The file is there (it is everywhere on my
computer now!!!)
I found some code where they apply the file path to a variable in single
quotes. Is that how it is done. Also I thought single quotes
A python interactive interpreter works by having the user type in some
code, compiling and running that code, then printing the results. For
printing, the results are turned into strings.
I would like make an interpreter which does this, without the last
part: i.e. where the results are
What/should I, can I do?
Fix your code?
def login():
global e2,e1
print e2.get()
print e1.get()
That should work.
Matt
--
http://mail.python.org/mailman/listinfo/python-list
text=Action?,command=self.V(a,b,c,d)).pack(anchor=W) doesn't even do
anything, what can I do to fix this problem?
I see many mistakes.
First: `command=self.V(a,b,c,d)' is actually calling self.V. You don't
want to call self.V, which will assing `command' to the return value,
you want to pass
On 8/24/07, Lamonte Harris [EMAIL PROTECTED] wrote:
How to fix my code, wth that doesn't help solve anything really.the Tkinter
tutorial doesn't even explain radio buttons correctly, let alone, everything
else. gah. can you give a answer that I can work from.
You asked, what can I do to fix
i have a very large project in visual studio2005-visual c++ in windowsxp.
i'd like to port it, or my next project, over to python.
is this possible without rewriting all my code?
are there multiple options to do this?
my project is so large, that entirely rewriting it
is actually no option.
While that's an interesting link, I was thinking of the named items like:
Numeric, (this one I know about.)
Image
ImageChops
ImageTk
time
binascii
tkMessageBox
tkSimpleDialog
The `image' ones are all part of PIL (Python Imaging Library) which is
a third party module
A friend of mine dropped off a copy of Sams Teach Yourself Python in
24 Hours published in 2000. I skimmed the first couple of chapters
looking for the interpreter version and the book was based on version
Python version 1.5.
Is this book still relevant? Should I toss it and look for
I heard I need to port C program to JPython first and compile it to native
JAVA. I don't know
anything about JPython. Is there a tool to do the porting? If not, what is
the quickest way to learn
JPython?
I'm assuming that you are refering to Jython. You probably want to
start by learning
Why do you think they are not?
Because they aren't. You even mentioned that a few operations that
aren't atomic. If operations are atomic it isn't necessarily because
of the design of the list, but the design of CPython. More
specifically the GIL. I don't mean to imply that you can't get a
My question is -- are python list operations atomic? If they are not,
then I assume I need to put some mutual exclusion around the append()
and pop() calls ?
They are not, but there is one included in the standard library:
http://docs.python.org/dev/lib/module-Queue.html
Matt
--
I thought finally always propagated the
exception all the way up the stack until it was handled.
Finally will propagate the exception up, unless another exception
occurs within the finally block. Since there is not (yet:
http://www.python.org/dev/peps/pep-3134/) exception chaining in
Python,
I am using Fedora Core 4 linux. Where should I look for _ssl.pyd ? I
am trying to build and use Python-2.5.1
I don't have access to that type of system. I do know that you need
OpenSSL to use ssl. It might be as simple as just finding and
installing OpenSSL for fedora. You can also find the
I built and installed python 2.5 from source and when I do this:
opener = urllib2.build_opener(SmartRedirectHandler(),
DefaultErrorHandler(), urllib2.HTTPSHandler())
I get this error.
AttributeError: 'module' object has no attribute 'HTTPSHandler'
What should I do?
You need `_ssl.pyd'
Which style convention is it referring to? Should these really be all
caps?
I think pylint is expecting that any variables declared outside of a
function should be constants with special meanings (similar to #define or
enum values in c). So, I guess to get rid of that message you should do
That code doesn't tell me anything. You are going to have to post a more
complete example to get help. Like, enough code so that I can run it and see
the same problem.
Also, I tried creating the image object outside class but it
gives a runtime error saying it is too early to create an image
Is there any way to check if an item in specific location in a multiple
dimension nested exist? For example something like:
if M_list[line][row][d] exist:
do_something_0
else:
do_something_1
Certainly:
code
try:
M_list[line][row][d]
except IndexError:
do_something_1
else:
How about broke instead of deprecated:
class Old:
... def __init__(self):
... self._value = 'broke'
... value = property(lambda self: self._value)
...
How is this broken? Properties are not supported for old-style classes.
They may not support features introduced in new-style
Could you use a set of tuples?
set([(1,2),(1,3),(1,2),(2,3)])
set([(1, 2), (1, 3), (2, 3)])
Matt
On 7/19/07, Alex Mont [EMAIL PROTECTED] wrote:
I have a 2-dimensional Numeric array with the shape (2,N) and I want to
remove all duplicate rows from the array. For example if I start out
That certainly is fast, unfortunately it doesn't pass all of the tests. I
came up with those tests so I don't know how important they are to the
original poster. I modified it and came up with a generator and a
non-generator version based (roughly) on your algorithm, that are almost as
quick, and
50 matches
Mail list logo