Re: Use GUI for Python

2007-09-17 Thread Jason
On Sep 17, 9:31 am, [EMAIL PROTECTED] wrote: > I am new to python as I have been a VB programmer. I am used to the > GUI interface, and was wondering if I had to choose between a GUI for > Python, which one should I go with? Thanks. > > Kou You need to be more specific. Do you mean that you are

Re: Keeping a database connection with a Singleton?

2007-09-19 Thread Jason
; am getting more and more comfortable with the basics of python, I > would like to know if I am missing something more "pythonic". > > So, what would you recommend? You don't need a way to make every instance the same. You need a way where every instance shares the same state. Ak

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread Jason
Y-axis component.) Depending on what you're doing, you might need the real part or the magnitude. It sounds a little bit like you're trying to represent something as a flatlander when you should be in Spaceland. (http:// en.wikipedia.org/wiki/Flatland) --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: list/get methods/attributes of a class?

2007-02-22 Thread Jason
Methods defined here: | | GetArgCount(self) | Show how many arguments were passed at instantiation. | | __init__(self, *args) | | -- | Data and other attributes defined here: | | __dict__ = | dictionary for instance variables (if de

Re: Using imaplib module with GMAIL's IMAP - hangs

2007-11-08 Thread Jason
lib >>> mail = imaplib.IMAP4_SSL('imap.gmail.com', 993) That worked for me. I could then use the login method to log into the mail server. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Tip of the day generator.

2007-11-28 Thread Jason
oup [8] to read badly formatted HTML. Word documents are much trickier, and it's usually easiest to use Microsoft Word to save to a plain text format. Hope this helps you out! --Jason [1] http://docs.python.org/lib/built-in-funcs.html [2] http://docs.python.org/lib/bltin-file-

Re: Class destructor -- strange behaviour

2007-12-07 Thread Jason
guarantees that your destructor has "deepcopy" binding that you want, even if the name has already been reassigned to None in your current module by the interpreter as it is shutting down. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: How does python build its AST

2007-12-07 Thread Jason
es the code block for the function into a function object, then assigns it to the name of the function. When Python hits a function call, it must look up the name in the current name dictionary. In any but that most simple cases, the name may not refer to its previous values: any intervening calls or statements could have rebound that name to another object, either directly, through side-effects, or even through the C interface. You can't call a function before its def statement is parsed any more than you can print the value of a variable before you assign anything to it. Unlike C, functions are not special under Python. Unlike C++, classes aren't terribly special either. They have syntactic sugar to help the coding go down, but they are only Python objects, and are bound to the same rules as all other Python objects. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuples !?!?

2007-12-13 Thread Jason
On Dec 11, 3:08 pm, [EMAIL PROTECTED] wrote: > On 11 Dez, 22:02, [EMAIL PROTECTED] wrote: > > > Ok. This is small code. > > > The problem is '2' != 2 there is a way of converting 'some number' in > > number ? > > > Thanks. > > > # -*- coding: cp1252 -*- > > import random > > import csv > > import s

Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Jason
or everything and calling setParent('..') to point to > the next object up in the hierarchy). But there's no reason (as far > as I know) that he couldn't create helper functions to wrap that with > something more sane. Let me add that, for lots of GUI layout, most programming languages are the wrong tool for the job. GUI layout involves tons of nested, almost boiler-plate type data. Use a tool to generate the layout that the code can load, and perform the few tweaks that you might need. This makes things far more sane, especially for anyone who has to maintain the layout later. The lack of such a layout tool is a weakness of your GUI library, not necessarily a problem with the program language. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: 3D plotting with python 2.5 on win32

2007-12-19 Thread Jason
t;wrapper" binary modules are unnecessary. They can work cross-platform from pure Python, calling directly into the C function code. Trust me, this is an excellent improvement. PyOpenGL probably too low-level for what you want, but it isn't dead yet. (It's just pining for the symbol table.) --Jason [1] http://docs.python.org/lib/module-ctypes.html -- http://mail.python.org/mailman/listinfo/python-list

Re: 3D plotting with python 2.5 on win32

2007-12-20 Thread Jason
On Dec 20, 8:48 am, anton <[EMAIL PROTECTED]> wrote: > Hi Jason, > > I know ctypes, my problem is not PyOpenGL itself, > but during my tests with different python based 3D tools, > some of them depend on PyOpenGL and since PyOPenGL > is only available for python 2.4

Re: Optional code segment delimiter?

2007-12-29 Thread Jason
a single line will be rightfully mocked by other Pythonistas. How is: print "This"; print "That" better than: print "This" print "That" I know which one is easier for me to read. > > I know I'll probably get yelled at for this ques

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Jason
s there are no valid string representations of NAN that can be converted to the special floating point value. Also, if you manage to create a nan under Windows, it displays as "1.#QNAN". Infinite values are also problematic. In almost all cases, it is far better to avoid infinite and NaN values. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: application error in python

2008-01-23 Thread Jason
u will also need to recompile all DLL libraries, such as wxPython, LXML, and the PIL. Pure Python modules and libraries will be unaffected. The easiest solution, however, is to use Python 2.5 and Visual Studio 2003. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: get the size of a dynamically changing file fast ?

2008-01-23 Thread Jason
hat > >> the file is flushed to disk and all problems are solved. > > >> cheers, > >> Stef Mientki > > > I almost asked if you were making sure you had flushed the data to the > > file...oh well. > > Yes, that's a small disadavantage of using a "high

Re: type, object hierarchy?

2008-02-03 Thread Jason
#x27;type' for each class you define. That doesn't mean that 'type' is a superclass. Try "isinstance(Dog, type)": it will return True. Type does inherit from object, but that's not what you're deriving from. The hierarchy that you're using is: Dog ^ | Mammal ^ | object As you notice, type isn't part of the object hierarchy for Dog. That's why it doesn't show up in the MRO. If you want to make Dog a subclass of type, you'd need to do: >>> class Dog(Mammal, type): ... pass ... >>> issubclass(Dog, type) True I don't know why'd you would want to do that, though. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: type, object hierarchy?

2008-02-04 Thread Jason
of class type, not a subclass of class type. Since class Dog is an instance of class type, class type is considered to be Dog's metaclass. You can create your own metaclasses. To quote another Pythoneer, if you think you need a metaclass, you probably don't. If you know you need a metaclass, you definitely do not need a metaclass. They are tricky and mind-bending. Hope this helps clear things up for you. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Double underscores -- ugly?

2008-02-19 Thread Jason
and out. They might stand out if the editor you used supported syntax highlighting. Personally, I find the examples with the plus and tilde (+, ~) to be more noisy and ugly than the underscores. Think of the underscores as a serene white-space day, with a simple black road that takes you to the special name. Or, you can wonder what I'm smoking when I code *grin* --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Why must implementing Python be hard unlike Scheme?

2008-02-20 Thread Jason
ject objects work. Since this is the top of Python's new-style classes, getting this right is imperative. I hope this gives you some idea on how to proceed. Python's grammar really isn't that difficult. Python uses a LL parser [2], while many languages uses LALR parsers [3]. The

Re: Simple - looking for a way to do an element exists check..

2008-02-22 Thread Jason
On Feb 22, 10:20 am, rh0dium <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a simple list to which I want to append another tuple if > element 0 is not found anywhere in the list. > > element = ('/smsc/chp/aztec/padlib/5VT.Cat', > '/smsc/chp/aztec/padlib', > '5VT.Cat', (33060)) > > element1 =

multiplication of lists of strings

2008-03-04 Thread Jason
is solved, I then will use each tuple as a key in a dict. I appreciate any assistance you can throw my way. Jason G -- http://mail.python.org/mailman/listinfo/python-list

python-list@python.org

2008-03-10 Thread Jason
DropTarget class to accomplish this, BTW.) [1] The demo package for your platform can be found at "http:// www.wxpython.org/download.php#binaries" --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Shortcutting the function call stack

2008-03-24 Thread Jason
nditional_value: raise SecondExcept( 5 ) # The following could even be put in your own function, # or in a wrapper or decorator for the First function. try: myvalue = First( 'Vikings!' ) except SecondExcept, exc: myvalue = exc.value When you need to use an exceptional pathway, use an exception. They aren't just for reporting errors. Hope this helps. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected string behaviour: txt = 'this' ' works'

2009-02-11 Thread Jason
>> from dis import dis >>> def f(): ... return 'This is ' 'an example.' ... >>> dis(f) 2 0 LOAD_CONST 1 ('This is an example.') 3 RETURN_VALUE >>> It's such a minor optimization, that you probably wouldn't see any effect on your program. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Breaking Python list into set-length list of lists

2009-02-11 Thread Jason
Hey everyone-- I'm pretty new to Python, & I need to do something that's incredibly simple, but combing my Python Cookbook & googling hasn't helped me out too much yet, and my brain is very, very tired & flaccid @ the moment I have a list of objects, simply called "list". I need to break it

Re: Selecting a different superclass

2008-12-18 Thread Jason
lePointSet else: PointSet = _PointSet Hope this helps. Python's dynamic nature loves you! --Jason -- http://mail.python.org/mailman/listinfo/python-list

Graphical object browser

2008-10-28 Thread Jason
ts. I was wondering if there is a simple tool like this out there somewhere. Preferably one that doesn't involve me installing a massive IDE, but I can't really be picky. Cheers, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Graphical object browser

2008-10-29 Thread Jason
Hooray! I discovered PyCrust. I made this script (for Linux - under Win, you could just have all but the first line as a python file and run it directly): #!/usr/bin/python import wx import wx.py.PyCrust if __name__ == '__main__' : app = wx.App() pc = wx.py.PyCrust.App(app) pc.MainLoo

Re: Graphical object browser

2008-10-30 Thread Jason
Yeah, PyCrust is in wxPython now. But I take back my initial excitement — it's freaking hard to use, despite its provision of a "pywrap" script (batch file under Windows). You certainly can't just replace "python /path/to/blah.py" with "pywrap /path/to/blah.py", especially if your script requires k

Re: Graphical object browser

2008-10-30 Thread Jason
Yeah, PyCrust is in wxPython now. But I take back my initial excitement — it's freaking hard to use, despite its provision of a "pywrap" script (batch file under Windows). You certainly can't just replace "python /path/to/blah.py" with "pywrap /path/to/blah.py", especially if your script requires k

Is there a GUI for informing a user of missing dependencies?

2009-05-12 Thread Jason
but I was wondering if there is an even more direct way. I was going to roll my own (eg. very simple Tkinter fallback error dialog if wxPython import fails, wxPython error dialog if anything else is missing); but I was wondering if such a system already exists out there. — Jason -- http://mai

Re: should I put old or new style classes in my book?

2008-05-29 Thread Jason
Python library use the old style. So, you might want to acknowledge that there are two ways of doing classes, that a lot of old code uses the old way. The new way adds some powerful new techniques that may be beyond the scope of your book. In Python 3.0, it won't matter, as everything is a new-style class anyway. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Sorting a List of Objects by an Attribute of the Objects Case-Insensitively

2008-04-08 Thread Jason
Hi folks-- Basically, I have a pressing need for a combination of 5.2 "Sorting a List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects by an Attribute of the Objects" from the Python Cookbook. My first guess isn't working: import operator def sort_by_attr(seq, attr): key=oper

Re: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively

2008-04-08 Thread Jason
On Apr 8, 8:26 pm, "David Harrison" <[EMAIL PROTECTED]> wrote: > On 09/04/2008, Jason <[EMAIL PROTECTED]> wrote: > > > Hi folks-- > > > Basically, I have a pressing need for a combination of 5.2 "Sorting a > > List of Strings Case-Inse

Re: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively

2008-04-09 Thread Jason
Thanks so much everyone! That works great, & (presumably) is way faster than the way I was doing it-- -- http://mail.python.org/mailman/listinfo/python-list

Re: Installed python 2.5 over 2.4 and lost installed packages

2008-04-28 Thread Jason
alled "easy- install.pth". All packages that Easy Install provided should be in there. [1] Found at: http://peak.telecommunity.com/DevCenter/EasyInstall --Jason -- http://mail.python.org/mailman/listinfo/python-list

CheddarGetter module for Python - easy recurring billing

2010-02-01 Thread Jason
get the latest version (currently 0.9). Hope others can benefit from it! - Jason -- http://mail.python.org/mailman/listinfo/python-list

Represent object type as

2010-03-25 Thread Jason
(This pertains to Python 2.5.4.) Cheers, — Jason [1] http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#data-types -- http://mail.python.org/mailman/listinfo/python-list

Re: Represent object type as

2010-03-25 Thread Jason
;__name__" attribute. > Warning: won't be very useful if your code still uses old-style classes. No, all the objects are new-style classes so that's fine. > Depends on what you do with this dict, DBUS etc. And of your definition > of "better", of course. Simple

How does GC affect generator context managers?

2010-11-30 Thread Jason
ncludes the finally clause... right? — Jason -- http://mail.python.org/mailman/listinfo/python-list

PyObject_SetAttrString - doesn't set instance attribute

2010-05-01 Thread Jason
except AttributeError: print "Didn't work!" When the MenuProviderTest is created, the output is: nautilus_python_object_instance_init called Setting magic parameter >From C: Result: 0 >From Python: Didn't work! (I've tried getattr and self.super_happy_magic, with the same effect.) Where am I going wrong? — Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: PyObject_SetAttrString - doesn't set instance attribute

2010-05-02 Thread Jason
s that in the Python snippet you > are calling getattr on the object that the C code refers to as > "object". object->instance is the PyObject, and I gathered that it was the correct thing to assign to from the fact that the address is identical as seen from C and Python. — Jason -- http://mail.python.org/mailman/listinfo/python-list

Temporary but named file with BSDDB

2010-06-13 Thread Jason
tween way to use the BSDDB module, where I can name the file I want to use but tell the module it's temporary so that it can be removed without my intervention? - Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Temporary but named file with BSDDB

2010-06-14 Thread Jason
On Jun 14, 12:34 pm, Tim Pinkawa wrote: > On Sun, Jun 13, 2010 at 11:01 PM, Jason wrote: > The tempfile.TemporaryFile class should do the job. This part is > probably of particular interest to you: Thanks! Since the bsddb functions require a filename (not a file object), I'm

How can I enumerate (list) serial ports?

2009-06-17 Thread Jason
show the user a list of "COM1","COM2", etc, or ttyS0, ttyS1, etc. At the moment I think they'll just have to type it into a box. Is there a known way to do this? Is there anyone who has a hack they're willing to share? Thanks, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I enumerate (list) serial ports?

2009-06-18 Thread Jason
or other platforms. Thanks for this pointer :) Cheers, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert hash to struct

2009-06-19 Thread Jason
Here's my general-purpose solution for doing this: class Dict2Class(object): """ Update like a dictionary, but expose the keys as class properties. Sweet! You can instantiate and update this practically any way you choose, and the values are available as class properties. >>> c

Re: Simple IRC library

2009-08-25 Thread jason
On 2009-08-24 01:39:21 -0600, devaru said: Hi all, I am new to Python language. I want to capture(either in database or a file) the conversation in IRC. Fed. Please suggest me some simple IRC library or code snippet for this. I have used the oyoyo library with success. It's pretty nice an

How to check something is in a list with rich-comparison objects?

2009-09-15 Thread Jason
ast): File "", line 1, in AttributeError: expecting wc_notify_action object for rich compare Is there a simple way around this? Thanks, Jason Heeris -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check something is in a list with rich-comparison objects?

2009-09-15 Thread Jason
I will raise this with pysvn, if I can ever find their issue reporting system. In the meantime, I suppose I can only do this by traversing the list with a loop and catching exceptions. Ugly, but seems to be the only way. On Sep 16, 2:39 am, "Gabriel Genellina" wrote: > Looks like a bug in pysvn.

Subclassing by monkey-patching

2010-09-04 Thread Jason
would even allow me to override the gio.File.monitor_directory() method to take the monitor returned by the original method and decide whether to make it recursive based on a parameter passed to monitor_directory(). Cheers, Jason PS. Asked a similar question on the pygtk list a few days ago: http://www.daa.com.au/pi

Re: Subclassing by monkey-patching

2010-09-05 Thread Jason
, same for all GObject properties, same for the usual methods. I'd basically have to re-write the entire class in Python, and then tack on my methods. Otherwise I have to write two sets of methods for anything that touches this wrapped object. Still, if it's the only way, sure. — Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Subclassing by monkey-patching

2010-09-05 Thread Jason
ndows/Mac, but FreeBSD, Solaris, etc. But it's looking more and more like I should give up that particular goal. Cheers, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Subclassing by monkey-patching

2010-09-05 Thread Jason
On Sep 6, 8:57 am, Jason wrote: > But it's looking more and more like I should give up > that particular goal. ...but on the other hand I just knocked together a pyinotify threaded watch system in about 50 lines. It's tempting to tell users of other platforms to write their

Cross compiling (i386 from amd64) with distutils

2010-11-07 Thread Jason
on.h:58, from src/noddy.c:1: /usr/include/python2.6/pyport.h:694:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." error: command 'gcc' failed with exit status 1 So is it possible to get distutils to cross compile so

Re: Cross compiling (i386 from amd64) with distutils

2010-11-07 Thread Jason
the actual distutils package, and somehow use that in my project instead of setup.py? — Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Cross compiling (i386 from amd64) with distutils

2010-11-07 Thread Jason
On Nov 8, 8:55 am, Jason wrote: > Do you know if virtualenv allows installing a Python environment with > a different architecture than that of the system Python install? I > suspect not, but maybe there's an option I don't know about. Found a better solution, which is to

Re: Cross compiling (i386 from amd64) with distutils

2010-11-08 Thread Jason
hine, so I'll stick with the "separate 32-bit installation" approach. Cheers, Jason -- http://mail.python.org/mailman/listinfo/python-list

Define macro when invoking setup.py

2010-11-08 Thread Jason
I'd like to be able switch between building my C extension with a certain preprocessor macro defined or not defined. I'm using the rudimentary distutils setup.py example given here: http://docs.python.org/extending/building.html Is there a command line option that distutils.core.setup() will inte

Re: Define macro when invoking setup.py

2010-11-08 Thread Jason
               ('HAVE_STRFTIME', None)], >           undef_macros=['HAVE_FOO', 'HAVE_BAR']) > > Note that define_macros requires a list of tuples each having two members. But can they be selected or set from the command line, so I can do, say, "setup.py build -DDEBUG=1"? — Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Define macro when invoking setup.py

2010-11-08 Thread Jason
On Nov 9, 10:56 am, Jason wrote: > But can they be selected or set from the command line, so I can do, > say, "setup.py build -DDEBUG=1"? Just answered my own question: there's an option for "build_ext" (NOT "build") that allows this. Thanks, Jason --

Re: How to run a python script twice randomly in a day?

2013-05-19 Thread Jason Friedman
>How to run a python script twice randomly in a day? Actually I want to run > my script randomly in a day and twice only I can think of two basic approaches. One, use crontab or some other similar functionality to call it exactly twice. Two, use crontab or some other similar functionality to

Re: suppress newlines in my script

2013-05-24 Thread Jason Friedman
> Here are two lines from the CSV file: > ,,172.20.{0}.0/27,172.20.{0}.32/27,172.20.{0}.64/27,29,172.20.{0}.96/27172.21.{0}.0/27,172.21.{0}.32/27,172.21.{0}.64/27,29,172.21.{0}.96/27 > GW:,,172.20.{0}.1,172.20.{0}.33,172.20.{0}.65,,172.20.{0}.97,,GW:,,172.21.{0}.1,172.21.{0}.33,172.21.{0}.65,,1

Python 2-3 compatibility

2013-06-02 Thread Jason Swails
e if possible. Any suggestions are appreciated. Thanks! Jason -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Candidate 352-392-4032 -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: The problem with "print"

2013-06-02 Thread Jason Swails
uld be quite upset if the interpreter tried to outsmart me and do it automagically as RR seems to be suggesting. And if you're actually debugging, then you typically only add a few targeted print statements -- not too hard to comment-out. If it is, and you're really that lazy, then by

Re: PyWart: The problem with "print"

2013-06-02 Thread Jason Swails
On Sun, Jun 2, 2013 at 11:10 PM, Dan Sommers wrote: > On Sun, 02 Jun 2013 20:16:21 -0400, Jason Swails wrote: > > > ... If you don't believe me, you've never hit a bug that 'magically' > > disappears when you add a debugging print statement ;-). >

Re: PyWart: The problem with "print"

2013-06-03 Thread Jason Swails
On Mon, Jun 3, 2013 at 1:12 PM, Ian Kelly wrote: > On Sun, Jun 2, 2013 at 6:16 PM, Jason Swails > wrote: > > I'm actually with RR in terms of eliminating the overhead involved with > > 'dead' function calls, since there are instances when optimizing in >

Re: PyWart: The problem with "print"

2013-06-03 Thread Jason Swails
On Mon, Jun 3, 2013 at 1:12 PM, Ian Kelly wrote: > On Sun, Jun 2, 2013 at 6:16 PM, Jason Swails > wrote: > > I'm actually with RR in terms of eliminating the overhead involved with > > 'dead' function calls, since there are instances when optimizing in >

Re: PyWart: The problem with "print"

2013-06-03 Thread Jason Swails
ack, sorry for the double-post. -- http://mail.python.org/mailman/listinfo/python-list

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Jason Swails
On Tue, Jun 4, 2013 at 11:44 AM, Rick Johnson wrote: > > This implicit conversion seems like a good idea at first, > and i was caught up in the hype myself for some time: "Hey, > i can save a few keystrokes, AWESOME!". However, i can tell > you with certainty that this implicit conversion is folly

Re: python netcdf

2013-06-05 Thread Jason Swails
ncfile.variables['time'].origin etc. etc. The variables and dimensions of a NetCDF file are stored in dictionaries, and the data from variables are accessible via slicing: time_data = ncfile.variables['time'][:] The slice returns a numpy ndarray. HTH, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Idiomatic Python for incrementing pairs

2013-06-07 Thread Jason Swails
If I was reading the second, it would take a bit to decipher. In this example, I don't see a better solution to what you're doing. All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Idiomatic Python for incrementing pairs

2013-06-08 Thread Jason Swails
ant data structures that behave like vectors but don't want to impose the numpy dependency on users. (Although I usually inherit from a mutable sequence so I can override __iadd__ and __isub__). It seemed overkill for the provided example, though... All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Jason Swails
ental (and at the very beginning of me learning and using Python). # beginner's crappy code range = [0, 20] # bunches of code for i in range(len(data)): if data[i] > range[0] and data[i] < range[1]: do_something TypeError: 'list' object is not callable... # what the heck does this mean?? That one drove me nuts. Took me hours to find. I still avoid rebinding builtins just from the memory of the experience :) --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: My son wants me to teach him Python

2013-06-13 Thread Jason Swails
ole for many tasks. With the exception of text based > games, the console is as useful for game programming as > [something not useful] > Just because you click through a GUI faster does not mean that everyone else does, too. And I've developed some Tkinter-based apps (that you can even download if you were so interested)---I did all the development on the command-line using vim and git. All the best, Jason [1] http://mail.python.org/pipermail/python-list/2013-March/642963.html [2] https://upload.wikimedia.org/wikipedia/commons/a/a7/Graham%27s_Hierarchy_of_Disagreement1.svg -- http://mail.python.org/mailman/listinfo/python-list

Re: My son wants me to teach him Python

2013-06-14 Thread Jason Swails
On Fri, Jun 14, 2013 at 3:21 AM, Chris Angelico wrote: > On Fri, Jun 14, 2013 at 4:13 PM, Steven D'Aprano > wrote: > > Here's another Pepsi Challenge for you: > > > > There is a certain directory on your system containing 50 text files, and > > 50 non-text files. You know the location of the dir

on git gc --aggressive [was Re: Version Control Software]

2013-06-16 Thread Jason Swails
quot;git gc --aggressive" before giving > those figures] > Off-topic, but this is a bad idea in most cases. This is a post including an email from Torvalds proclaiming how and why git gc --aggressive is dumb in 99% of cases and should rarely be used: http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/ All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Version Control Software

2013-06-16 Thread Jason Swails
tracks content, not files). That being said, from what I've read both git and mercurial have their advantages, both in the performance arena and the features/usability arena (I only know how to really use git). I'd certainly take a DVCS over a centralized model any day. All the best, Jason

Re: Using Python to automatically boot my computer at a specific time and play a podcast

2013-06-16 Thread Jason Swails
is sort of thing possible > in Python? > Python cannot do this by itself, as has already been mentioned. If you're using a Mac, you can schedule your computer to turn on (and/or off) using System Preferences->Energy Saver->Schedule... Then run a Python script in a cron job. In fact

Re: python-django for dynamic web survey?

2013-06-18 Thread Jason Friedman
> Hi guys! > > Please help me with your advices and ideas. > > I need to create a web survey that will dynamically (randomly) select > questions and descriptions from a dataset, present them to users, collect > their answers and store them back in the dataset. (Every user gets > different set of qu

How much memory does Django consume compared to Rails?

2013-06-19 Thread Jason Hsu
I have deployed two Ruby on Rails sites on WebFaction, and Passenger Rack takes up around 60 MB of memory apiece. I was planning on replacing my Drupal web sites with Rails, but I'm now considering replacing these Drupal sites with Django. Given that the baseline memory consumption for a Rails

Finding all instances of a string in an XML file

2013-06-20 Thread Jason Friedman
I have XML which looks like: The "Property X" string appears twice times and I want to output the "path" that leads to all such appearances. In this case the output would be: LEVEL_1 {}, LEVEL_2 {"ATTR": "hello"}, ATTRIBUTE {"NAME": "Property X",

Re: Finding all instances of a string in an XML file

2013-06-21 Thread Jason Friedman
Thank you Peter and Dieter, will give those thoughts a try and report back. -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding all instances of a string in an XML file

2013-06-23 Thread Jason Friedman
> xml = """ > > > > > > > > > > > > > > """ > > import xml.etree.ElementTree as etree > > tree = etree.fromstring(xml) > > def walk(elem, path, token): > path += (elem,) > if token in elem.attrib.values(): > yield path > for child i

Re: Why is the argparse module so inflexible?

2013-06-27 Thread Jason Swails
catches an ArgumentError to eliminate the internal exception handling and instead allow them to propagate the call stack. All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is the argparse module so inflexible?

2013-06-27 Thread Jason Swails
re. Of course, in RRsPy4k this whole module will just be replaced with "raise PyWart('All interfaces must be graphical')" and this whole thread will be moot. :) All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: FACTS: WHY THE PYTHON LANGUAGE FAILS.

2013-06-27 Thread Jason Friedman
> I was hoping to have a good laugh. :| > > Although I wouldn't call it hostile. > > I think the python community is being educated in how to spam and troll at > the same time. > It is possible the OP has a mental disease, which is about as funny as heart disease and cancer and not blameworthy.

Re: Regular expression negative look-ahead

2013-07-01 Thread Jason Friedman
Found this: http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python . This pattern seems to work: pattern = re.compile(r"^(?!.*(CTL|DEL|RUN))") But I am not sure why. On Mon, Jul 1, 2013 at 5:07 PM, Jason Friedman wrote: > I have table

Regular expression negative look-ahead

2013-07-02 Thread Jason Friedman
I have table names in this form: MY_TABLE MY_TABLE_CTL MY_TABLE_DEL MY_TABLE_RUN YOUR_TABLE YOUR_TABLE_CTL YOUR_TABLE_DEL YOUR_TABLE_RUN I am trying to create a regular expression that will return true for only these tables: MY_TABLE YOUR_TABLE I tried these: pattern = re.compile(r"_(?!(CTL|DEL|R

Re: Regular expression negative look-ahead

2013-07-03 Thread Jason Friedman
> Huh, did not realize that endswith takes a list. I'll remember that in > the future. > > This need is actually for http://schemaspy.sourceforge.net/, which allows > one to include only tables/views that match a pattern. > > Either there is a bug in Schemaspy's code or Java's implementation of >

Re: Regular expression negative look-ahead

2013-07-03 Thread Jason Friedman
n Kelly wrote: > On Mon, Jul 1, 2013 at 8:27 PM, Jason Friedman wrote: > > Found this: > > > http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python > . > > > > This pattern seems to work: > > pattern = re.compile(r"

Re: Important features for editors

2013-07-04 Thread Jason Swails
On Thu, Jul 4, 2013 at 2:52 PM, Ferrous Cranus wrote: > Στις 4/7/2013 9:40 μμ, ο/η Grant Edwards έγραψε: > > On 2013-07-04, ?? wrote: >> >>> >>> If you guys want to use it i can send you a patch for it. I know its >>> illegal thing to say but it will help you use it without buying it. >

Re: Editor Ergonomics [was: Important features for editors]

2013-07-08 Thread Jason Friedman
I am right-handed and use a lefty-mouse about 50% of the time. It was difficult at first, now I'm almost as fast lefty as righty. As has been stated by others, changing the muscles being used reduces the impact on any one of them. -- http://mail.python.org/mailman/listinfo/python-list

Concurrent writes to the same file

2013-07-10 Thread Jason Friedman
Other than using a database, what are my options for allowing two processes to edit the same file at the same time? When I say same time, I can accept delays. I considered lock files, but I cannot conceive of how I avoid race conditions. -- http://mail.python.org/mailman/listinfo/python-list

Re: Callable or not callable, that is the question!

2013-07-11 Thread Jason Swails
e, you get back to the expected behavior Python 3.3.2 (default, Jun 3 2013, 08:29:09) [GCC 4.5.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class X: ... def example(self): pass ... test = e

Re: Concurrent writes to the same file

2013-07-11 Thread Jason Friedman
> > https://bitbucket.org/cameron_simpson/css/src/374f650025f156554a986fb3fd472003d2a2519a/lib/python/cs/fileutils.py?at=default#cl-408 > > That looks like it will do the trick for me, thank you Cameron. -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange behaviour with os.linesep

2013-07-23 Thread Jason Swails
r\r\n') >>> l.close() on UNIX and open the resulting file in gedit, it is double-spaced, but if I just dump it to the screen using 'cat', it is single-spaced. If you want to make your code a bit more cross-platform, you should strip out all types of end line characters from the strings before you write them. So something like this: with open('writetest.py', 'w') as outf: for s in strings: outf.write(s.rstrip('\r\n')) outf.write(L_SEP) Hope this helps, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter progress bar

2013-07-23 Thread Jason Swails
app.pack(expand=1, fill=tk.BOTH) root.mainloop() This is a simple stand-alone app that (just) demonstrates how to use the ttk.Progressbar widget. HTH, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange behaviour with os.linesep

2013-07-23 Thread Jason Swails
#x27;, 'r') as inf: for l in lines: print(l, len(l)) It's also fewer lines of code. ('# -*- coding: utf-8 -*-\r\n', 25) > ('import os\r\n', 11) > ('import sys', 10) Then it seems like there is an issue with your text editors that do not play nicely with DOS-style line endings. Gedit on my linux machine displays the line endings correctly (that is, '\r\n' is rendered as a single line). Good luck, Jason -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   10   >