Re: This Python 3 is killing Python thread is killing me.

2014-07-16 Thread Jason Swails
ced misconceptions. [http://xkcd.com/386/] My life lurking and learning on Python-list has been dramatically improved since I began to instantiate filters, I highly recommend it. Cheers, Jason [1] Seen one and you've seen them all, and I'm no unicode expert. -- https://mail.python.org/mailman/listinfo/python-list

Re: This Python 3 is killing Python thread is killing me.

2014-07-16 Thread Jason Swails
ing or useless retaliation thereof". With the volume of material available on the web, I try to be careful not to make a poor impression with anything I author (although that is unavoidable sometimes). All the best, Jason P.S. And nobody will think you're just like if you don't bite back in a public forum. -- https://mail.python.org/mailman/listinfo/python-list

Re: networkx plot random graph Error

2014-07-16 Thread Jason Swails
to unpack The traceback for this exception ends inside the networkx code and either indicates a bug in the networkx code or an input error that is not gracefully handled. My suggestions are twofold: 1) Upgrade to the latest release. If this is a bug, it's very possible that it was fixed in later releases (1.7 is over 2 years old and there have been a couple major releases since then. 2) Sign up for the networkx mailing list and ask your question there. You are certain to get a faster and more relevant answer. (See the "mailing list" link here: http://networkx.github.io/) Hope this helps, Jason -- https://mail.python.org/mailman/listinfo/python-list

Re: My sys.excepthook dies painfully

2014-07-23 Thread Jason Swails
r [mylogging] Jul 23 16:02:30 batman ERROR:Uncaught : name 'foo' is not defined [mylogging] I tried it with python2.2 through python2.7 (python 2.2 and earlier did not have the logging module). I'm not sure how the "mylogger" variable is getting set to None in your my_error_handler callback, but I don't see how that can possibly be happening with the provided code... All the best, Jason -- https://mail.python.org/mailman/listinfo/python-list

Re: My sys.excepthook dies painfully

2014-07-23 Thread Jason Swails
On Wed, Jul 23, 2014 at 6:30 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Wed, 23 Jul 2014 13:02:51 -0700, Jason Swails wrote: > > > I'm not sure how the "mylogger" variable is getting set to None in your > > my_error_ha

Re: Why does str not have a __radd__ method?

2014-08-13 Thread Jason Swails
7; + 1 and 'this' + 1): >>> 'this' + 1 Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects >>> u'this' + 1 Traceback (most recent call last): File "", line 1, in TypeError: coercing to Unicode: need string or buffer, int found All the best, Jason -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] Question about Git branches

2014-09-16 Thread Jason Swails
use "git diff" or "git difftool" to directly compare specific files or folders between branches or different revisions in diverged history between branches. I wouldn't expect you to know all of this git-magic from the outset, but you will learn it as you need to. Ass

executing arbitrary statements

2011-09-30 Thread Jason Swails
;donate" their scripts to others that may run them as black boxes). Is it enough to disallow import statements, thereby not giving direct access to the sys and os modules? I know more or less what I want to do, but I'd also appreciate any experienced input/advice/suggestions. Thanks! Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Jason Swails
Circle (and if the same attribute is defined in both places, the definition in Circle overrides that definition). Thus, in this case we can define a Circle with a center and radius (much easier than vertices!), and we can tell Circle how we want the vertices defined to get as close an approximation to a circle as we want. HTH (I'm sure others can explain this better than I can), Jason -- http://mail.python.org/mailman/listinfo/python-list

CSV writer question

2011-10-23 Thread Jason Swails
ypes of files? Tips, answers, comments, and/or suggestions are all welcome. Thanks a lot! Jason As an afterthought, I suppose I could always subclass the csv.writer class and add the reference I want to that, which I may do if there's no other convenient solution. -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV writer question

2011-10-24 Thread Jason Swails
On Mon, Oct 24, 2011 at 2:08 AM, Chris Rebert wrote: > On Sun, Oct 23, 2011 at 10:18 PM, Jason Swails > wrote: > > > unless, of course, I add an explicit reference to track the open file > object > > and manually close or flush it > > (but I'd like to avoid i

Re: CSV writer question

2011-10-24 Thread Jason Swails
On Mon, Oct 24, 2011 at 3:03 AM, Chris Angelico wrote: > On Mon, Oct 24, 2011 at 4:18 PM, Jason Swails > wrote: > > my_csv = csv.writer(open('temp.1.csv', 'wb')) > > > > Have you confirmed, or can you confirm, whether or not the file gets > close

Re: Review Python site with useful code snippets

2011-10-29 Thread Jason Friedman
On Wed, Oct 26, 2011 at 3:51 PM, Chris Hall wrote: > I am looking to get reviews, comments, code snippet suggestions, and > feature requests for my site. > I intend to grow out this site with all kinds of real world code > examples to learn from and use in everyday coding. > The site is: > > http:

(n00b) Tkinter trouble

2011-11-13 Thread Jason Swails
op.mainloop() I'm really kind of running around in the dark here, so any advice or explanation is appreciated. Thanks! Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: (n00b) Tkinter trouble

2011-11-13 Thread Jason Swails
On Sun, Nov 13, 2011 at 1:27 PM, Jason Swails wrote: > Hello, > > I'm trying my hand at creating a Tkinter application, but not having much > luck. I'm trying to have my top level window be a series of buttons with > different options on them. Every time a button is pre

Re: (n00b) Tkinter trouble

2011-11-14 Thread Jason Swails
On Mon, Nov 14, 2011 at 3:49 AM, Chris Angelico wrote: > On Mon, Nov 14, 2011 at 6:11 PM, Jason Swails > wrote: > > Then, I can reactivate all of the buttons in the destroy() method before > > calling the destroy() method of Toplevel on self. > > Small side point that

Re: (n00b) Tkinter trouble

2011-11-15 Thread Jason Swails
raw() method on the window during the constructor of the *new* window and execute .deiconify() on it during the new window's destroy() method (before calling Toplevel's destroy on self). I still like the first way better. Thanks! Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: (n00b) Tkinter trouble

2011-11-16 Thread Jason Swails
On Tue, Nov 15, 2011 at 10:49 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 2:02 PM, Jason Swails > wrote: > > Apparently I could not do what I was wanting to (state=DISABLED is not a > > valid option to Toplevel). What I wanted to do was something similar to > &g

Re: tkinter

2011-11-26 Thread Jason Swails
e variable that you set is useless unless you plan to use the value (or if there's a case where you may use it). If such a case exists, then you'll need a reference to that variable in the relevant scope you're dealing with. Hope this helps, Jason On Nov 26, 2011, at 4:42 P

Debug python from DLL callback?

2011-11-30 Thread Jason Veldicott
Hi, I am wondering if anyone here might be able to suggest if there is a way of switching over from python execution into debug mode of an IDE, from python code that is executed as a callback from a C++ DLL? Thanks Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: merging argparse parsers

2011-12-23 Thread Jason Friedman
> I would like to have something like > > merged_parser = LoggingParser() + OtherParser() > > Which should create an argument parser with all the options composed. > I have used parent parsers. http://docs.python.org/py3k/library/argparse.html#parents I think in your case merged_parser would bec

Re: modifying a time.struct_time

2011-12-23 Thread Jason Friedman
On Fri, Dec 16, 2011 at 10:44 AM, Chris Angelico wrote: > On Fri, Dec 16, 2011 at 8:45 PM, Ulrich Eckhardt > wrote: >> I'm trying to create a struct_time that is e.g. one year ahead or a month >> back in order to test some parsing/formatting code with different dates. > > Do you need it to be one

Re: Regular expressions

2011-12-26 Thread Jason Friedman
> On Tue, Dec 27, 2011 at 10:45 AM, mauricel...@acm.org > wrote: >> Hi >> >> I am trying to change to . >> >> Can anyone help me with the regular expressions needed? > > A regular expression defines a string based on rules. Without seeing a > lot more strings, we can't know what possibilities the

Re: Regular expressions

2011-12-26 Thread Jason Friedman
> Thanks a lot everyone. > > Can anyone suggest a good place to learn REs? Start with the manual: http://docs.python.org/py3k/library/re.html#module-re -- http://mail.python.org/mailman/listinfo/python-list

Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Jason Friedman
> Suppose I'm creating a class that represents a bearing or azimuth, > created either from a string of traditional bearing notation > ("N24d30mE") or from a number indicating the angle in degrees as > usually measured in trigonometry (65.5, measured counter-clockwise > from the x-axis).  The class

Python powering giant screen in Times Square

2011-12-31 Thread Jason Ford
ebook, Twitter, Instagram, Google+, Foursquare, and other sources. So if you happen to be in Times Square for the crazy party today, tell the people around you that big social media screen is powered by Python! - Jason (founder of FeedMagnet) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python lib for creating Database tables

2012-01-11 Thread Jason Friedman
> Hello All, > > I just made something pretty simple that I intend to use while creating > database tables. It is still in the basic form, and much needs to be added. > However, I use introspection to make it a bit easier and less work on the > user. > > I would want my code to be reviewed by this

How to remove ellipses from long paths in traceback?

2012-01-12 Thread Jason Veldicott
Hi, Long paths in python traceback are contracted with ellipses. eg: TclError: couldn't load library "C:/Python26/tcl/tk8.5/../../bin/tk85.dll" Is there any way to see the full path? Surprisingly, search didn't reveal an answer to this question. Thanks Jason -- ht

logging and httphandler

2012-01-13 Thread Jason Friedman
I am logging to my Apache web server, using this Apache format: LogFormat "%{%Y-%m-%d %H:%M:%S}t %U %q" scriptlog CustomLog /var/log/apache2/script.log scriptlog My code is as follows: #!/usr/bin/env python3 import logging, logging.handlers, sys logger = logging.getLogger('simple_example') logge

Re: scientific notation in legend (pylab)

2012-01-14 Thread Jason Friedman
> I I would like to have numbers expressed in scientific notation in > legend annotations. Does anybody know how to do that? > Not sure why legend annotations makes the problem different, but perhaps this is a start: $ python3 Python 3.2 (r32:88445, Jun 11 2011, 10:38:04) [GCC 4.4.3] on linux2 Ty

Re: why i can get nothing?

2012-01-15 Thread Jason Friedman
> here is my code : > import urllib > import lxml.html > down='http://download.v.163.com/dl/open/00DL0QDR0QDS0QHH.html' > file=urllib.urlopen(down). > read() > root=lxml.html.document_fromstring(file) > tnodes = root.xpath("//a/@href[contains(string(),'mp4')]") > for i,add in enumerate(tnodes): >  

Re: scientific notation in legend (pylab)

2012-01-18 Thread Jason Friedman
> thank you, I am trying to learn python, but I am having a hard to find > a good introduction to it. Try this: http://docs.python.org/py3k/tutorial/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Formatting a column's value output

2013-02-03 Thread Jason Friedman
> One of the difficulties on this list is that we don't have > two-dimensional people. Even our worst trolls have some redeeming > features. I can't just dismiss Ferrous out of hand... Indeed, and that is a "problem" with humanity in general. It is proof that God (or the universe) has a sense of h

Be first to Profit from the exploding mobile application industry

2013-02-04 Thread Jason Inch
Secure your position during Pre-Launch! http://www.TheAppThatPays.ca One of a kind, mobile application that makes it possible for the average, every day person, to profit. Check it out! -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Namespace asinitiy and the folly of the global statement

2013-02-11 Thread Jason Swails
ult of the work I do). Having no previous knowledge of any other GUI toolkit (and really only writing 2 or 3 _real_ GUIs total), it wasn't hard to pick up enough from effbot/stackoverflow/tkinter documentation to get a working GUI with (what I think is) decent code organization. Just my

Comparing types

2013-02-16 Thread Jason Friedman
I want to tell whether an object is a regular expression pattern. Python 3.2.3 (default, Oct 19 2012, 20:10:41) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> s = "hello" >>> type(s) >>> isinstance(s, str) True >>> my_pattern = re.co

Re: call from pthon to shell

2013-02-16 Thread Jason Friedman
import os os.system("i=3") > 0 os.system("echo $i") > > 0 > > why i can not get the value of i? Each call to os.system starts a new shell. Think about what would happen if you opened a terminal and typed: $ i=3 Then, close that terminal and open a new one. You would not be surpr

Re: request of information

2013-02-17 Thread Jason Swails
ot;circle.py", line 1 > >> syntax error: invalid syntax > Look at the first line of circle.py. This error says there is a syntax error there. If you can't figure out what is wrong with that line, you'll have to post that to the list in order to get help. (You'll benefit greatly if you can figure it out yourself -- that's the best way to learn). Good luck, Jason -- http://mail.python.org/mailman/listinfo/python-list

NamedTemporaryFile does not match documentation

2013-02-21 Thread Jason Friedman
Python 3.2.2 (default, Feb 14 2012, 08:06:31) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from tempfile import NamedTemporaryFile >>> f = NamedTemporaryFile(delete=False) >>> f >>> f.name '/tmp/tmpqxnd_4' >>> f.write(

Re: NamedTemporaryFile does not match documentation

2013-02-21 Thread Jason Friedman
> NamedTemporaryFile by default opens a file in binary mode ('w+b'). Write > bytes or specify text mode. > f.write(b"Hello World!\n") > 13 ft = NamedTemporaryFile('w+', delete=False) ft.write("Hello World!\n") > 13 Thank you Chris and Serhiy, that helped. I'm inclined to open a doc

Re: NamedTemporaryFile does not match documentation

2013-02-21 Thread Jason Friedman
> Yep, that looks like a docs bug (it was probably copied straight in > from the 2.x docs). Nice and easy to fix, you could submit a patch > with the bug report and make the devs love you! Done: http://bugs.python.org/issue17271. -- http://mail.python.org/mailman/listinfo/python-list

Re: Do you feel bad because of the Python docs?

2013-02-26 Thread Jason Swails
gun via trolling rants notwithstanding). But he's ranting on his blog; not a big deal really. --Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Jason Friedman
> Python has a nice Tutorial for beginners. It is an integral part of the doc > set. To ignore that (and the indexes) in discussing the usability of Python > docs by beginners is to lie. (If beginners who actually read the tutorial > have problems with particular paragraphs, improvements can be and

Re: Speeding up Python's exit

2013-03-01 Thread Jason Swails
s on the system. If a file object's destructor is not called when the Python interpreter exits and it's up to the OS to flush the file buffers to disk, you can't be sure that it will do so. And as Antoine pointed out, POSIX standard doesn't require that they do. All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it correct this way to inherit from a list?

2013-03-03 Thread Jason Swails
pre-declared and throws TypeError if you try to pass it a bad variable type). You can then proceed to override the __add__, __sub__, __mul__, and __div__ methods (and the in-place versions of these operators) to mimic vector operations. (By default, __add__ appends the rhs to the lhs and returns a co

Why is Ruby on Rails more popular than Django?

2013-03-06 Thread Jason Hsu
I'm currently in the process of learning Ruby on Rails. I'm going through the Rails for Zombies tutorial, and I'm seeing the power of Rails. I still need to get a Ruby on Rails site up and running for the world to see. (My first serious RoR site will profile mutual funds from a value investor'

Re: PyWart: NameError trackbacks are superfluous

2013-03-17 Thread Jason Swails
approach is that you have to actually write that extra 8 lines of code, and I get to keep the behavior I like rather than being forced into the (inconsistent) behavior you would prefer I use instead. But since the 8 lines has been provided to you here free of charge, the only real cost for you is how I like my NameErrors given to me. I hereby leave you enlightened. Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Python GUI questions

2013-03-19 Thread Jason Swails
word.count(character) > > I'm just struggling with only how to create an object that will hold a > single character that the user will enter. > This is tricky. The approach I would take is to generate an entry widget and then bind all key-press events in that widget to a method that checks how long the input string is. If it is longer than a single character, reject the new letter and optionally raise an alert (using, e.g., tkMessageBox.showwarning). If you want the count on the button to be updated continuously, you'll need to update that counter every time either the input string or character is changed. Good luck, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator help

2013-03-27 Thread Jason Swails
MyClass. This is a very simple type of decorator, but hopefully helps illustrate what decorators are. There is a particularly good thread on SO with information about decorators here: http://stackoverflow.com/questions/739654/understanding-python-decorators Hope this helps, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator help

2013-03-27 Thread Jason Swails
> self.y = y > And here as well. It's potentially worth pointing out that this code will actually compile. It will even run, assuming you provide MyClass with a single argument. But it will always return None :). As per usual, the response was thorough and helpful -- I appreciate responses like these and how they've helped improve my command of Python. All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Export data from python to a txt file

2013-03-29 Thread Jason Swails
a 3 t 5 q 6 r 10 s which is obviously not what you want. The following code will do what you want (although there are ways of doing this in less code, this is the most straightforward): f.write('a\t') for element in a: f.write(str(element) + '\t') f.write('\n') f.write('b\t') for element in b: f.write(str(element) + '\t') f.write('\n') HTH, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Jason Swails
y is available as shared memory across all 512 cores. And that's nothing---it can be configured with up to 64 TB of global shared memory: http://www.sgi.com/products/servers/uv/configs.html Impressed? :) All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Installation on Mac OSX 10.6.8 doesn't create the folder: /System/Library/Frameworks/Python.framework/Versions/2.7/

2013-04-02 Thread Jason Swails
/opt/local). If all else fails, upgrade to 10.7 ;). Good luck, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter

2013-04-02 Thread Jason Swails
you run your code? Annotating your code with what you expect each segment to do is even better -- it lets us quickly correct misconceptions. The more information you can provide, the more targeted help we can give. Simply saying "I need a program to do X" is unlikely to get a respons

Re: Tkinter

2013-04-02 Thread Jason Swails
tains a handy function that does just this: askinteger. So add a call: numero = tkSimpleDialog.askinteger('Window Title', 'Please insert the number of input values you want') window = makeWidgets(numero) window.mainloop() I leave to you the task of bringing tkSimpleDialog into your namespace. Good luck, 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: Help with python code!

2013-04-02 Thread Jason Friedman
> Thanks for your replies. Just to be clear this is for a interview and they > would like me to figure out what the code does and come back with some test > cases. I don't need to code the tests, just give some high level tests. As > far as I can make out it is some system where you input your name

Re: Tkinter

2013-04-03 Thread Jason Swails
nstance (or the yview method of your Canvas instance if you want to scroll vertically). HTH, Jason [1] http://effbot.org/zone/tkinter-scrollbar-patterns.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: In defence of 80-char lines

2013-04-04 Thread Jason Swails
I regularly break my rule is for regular expressions (at some point I may embrace re.X to allow me to break those up, too). All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: In defence of 80-char lines

2013-04-04 Thread Jason Swails
weight=wx.BOLD, > faceName="FreeSans", > +otherValue=42, > ) > +1 I wasn't aware you could do this (superfluous trailing commas), although I admit it hadn't occurred to me to try. I use git for virtually everything, and I regularly parse diffstats -- this would make them much easier to grok. (It's an incredibly helpful bug-tracking technique) Thanks! Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: In defence of 80-char lines

2013-04-04 Thread Jason Swails
On Thu, Apr 4, 2013 at 8:39 AM, Roy Smith wrote: > In article , > Jason Swails wrote: > > > The only time I regularly break my rule is for regular expressions (at > some > > point I may embrace re.X to allow me to break those up, too). > > re.X is a pretty coo

Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding

2013-04-04 Thread Jason Swails
rce it to take focus. Note that focus_force() is often considered 'impolite'---it's akin to that kid that always needs to be the center of attention. Of course it's not as bad as master.grab_set_global :) If your application already has 'focus', then you can use

Re: Python 3.3 Tkinter Fullscreen - Taskbar not Hiding

2013-04-04 Thread Jason Swails
On Thu, Apr 4, 2013 at 1:30 PM, Rotwang wrote: > On 04/04/2013 14:49, Jason Swails wrote: > >> I've added some comments about the code in question as well... >> >> On Wed, Apr 3, 2013 at 11:45 PM, > <mailto:teslafreque...@aol.com**>> wrote: >> >&

Re: In defence of 80-char lines

2013-04-04 Thread Jason Swails
ble width depending on > the unicode block (obvious reasons), speaking of a "text > width" in chars has not even a sense. > Let's log this as an exception to the rule of 80. There are plenty of threads not-about-Unicode-but-are-now-about-Unicode that we don't have to create another one. Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: I hate you all

2013-04-06 Thread Jason Friedman
> Am I the only one here who has used a typewriter? > > I used one. And http://en.wikipedia.org/wiki/White-Out. And http://en.wikipedia.org/wiki/Correction_tape. My wife typed her dissertation on this: http://en.wikipedia.org/wiki/File:Hardwarewordprocessor.png. -- http://mail.python.org/mailma

Re: classes and sub classes?

2013-04-14 Thread Jason Friedman
> NwInvDb = NetworkInventoryDatabase, yes you are correct, it creates the database handle and makes it ready for use. I am interested in opinions. I for one dislike abbreviations on the theory that programs are read more than they are written. I would probably use this variable name: network_in

Re: Preparing sqlite, dl and tkinter for Python installation (no admin rights)

2013-04-18 Thread Jason Swails
he supercomputer staff requesting that they install the software you need. There may be other 'gotchas' associated with installing certain software on supercomputers that the staff would know best. Good luck, Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: [TYPES] The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-18 Thread Jason Wilkins
Warning, this is a bit of a rant. That paragraph from Wikipedia seems to be confused. It gives the fourth paradigm as "declarative" but then says "first order logic for logic programming". It seems somebody did an incomplete replacement of "declarative" for "logic". Wikipedia is often schizophr

Re: [TYPES] The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-18 Thread Jason Wilkins
I don't quite think I understand what you are saying. Are you saying that mathematical models are not a good foundation for computer science because computers are really made out of electronic gates? All I need to do is show that my model reduces to some basic physical implementation (with perhap

itertools.groupby

2013-04-20 Thread Jason Friedman
I have a file such as: $ cat my_data Starting a new group a b c Starting a new group 1 2 3 4 Starting a new group X Y Z Starting a new group I am wanting a list of lists: ['a', 'b', 'c'] ['1', '2', '3', '4'] ['X', 'Y', 'Z'] [] I wrote this: #!/usr/bin/python3

Re: itertools.groupby

2013-04-21 Thread Jason Friedman
#!/usr/bin/python3 > from itertools import groupby > > def get_lines_from_file(file_name): > with open(file_name) as reader: > for line in reader.readlines(): > yield(line.strip()) > > counter = 0 > def key_func(x): > if x.startswith("Starting a new group"): > g

Remove some images from a mail message

2013-04-21 Thread Jason Friedman
I will be receiving email that contains, say, 10 images, and I want to forward that message on after removing, say, 5 of those images. I will remove based on size, for example 1679 bytes. I am aware that other images besides the unwanted ones could be 1679 bytes but this is unlikely and the impac

Re: Remove some images from a mail message

2013-04-23 Thread Jason Friedman
import os import sys import tempfile IGNORE_SET = set((588, 1279, 1275, 1576, 1272, 1591,)) IMAGE = "image" TEXT = "text" PLAIN = "plain" SUBJECT = "Subject" FROM = "From" TO = "To" DATE = "Date" WRITE_BINARY = "wb&quo

Re: Cannot build Python 2.4.2 for Cygwin

2005-12-28 Thread Jason Tishler
in.com/ml/cygwin-announce/2004-01/msg00020.html > [snip] > > Does anyone have an idea what is wrong? Yes, upgrading to the latest Cygwin should fix your build problem. Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8

Re: Resource temporarily unavailable launching idle under cygwin

2006-08-08 Thread Jason Tishler
.exe: *** fatal > error - C:\cygwin\bin\python2.4.exe: *** unable to remap > C:\cygwin\bin\tk84.dll to same address as parent(0x1889) != 0x18D2 You need to rebase your system: http://www.google.com/search?hl=en&q=cygwin+python+%22unable+to+remap%22 Jason -- PGP/GPG

Re: trouble with replace

2006-08-12 Thread Jason Nordwick
>>> pats = ['abcdef', 'defgef', 'effwer'] >>> reps = ['highway', 'news', 'monitor'] >>> s = 'defgefabcdefy\n\n\n effwerbyuuuterrfr' >>> reduce(lambda x,y: x.replace(*y), zip(pats,reps), s) 'newshighwayy\n\n\n monitorbyuuuterrfr' f pemberton wrote: > I have a string (xdata) and theres a

Re: Recurse Directories and process files in directory

2006-08-12 Thread Jason Nordwick
Use os.system to execute a string and os.walk to get a recursive list of files >>> def processdir(curdir,subdirs,files): ... map(lambda f:os.system('\\cygwin\\bin\\wc -l "%s"' % f), [curdir+os.sep+x for x in files]) ... >>> map(lambda x:processdir(*x), os.walk('\\dev\qclient')); 6 \dev\qclie

Re: yet another noob question

2006-08-13 Thread Jason Nordwick
def pr(x): print(x) >>> x=map(pr,[x for x in xrange(11,56) if '1'<=min(str(x)) and >>> max(str(x))<='5']) 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55 mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number an

Re: yet another noob question

2006-08-13 Thread Jason Nordwick
Or without filter: from operator import add def pr(x): print x def cross(x,y): return reduce(add, [[a+b for b in y] for a in x]) x=map(pr, reduce(cross, [map(str,range(1,6))]*5)) mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and

Re: yet another noob question

2006-08-13 Thread Jason Nordwick
better (sorry, still learning Python): def cross(x,y): return [a+b for a in x for y in b] Jason Nordwick wrote: > Or without filter: > > from operator import add > def pr(x): print x > def cross(x,y): return reduce(add, [[a+b for b in y] for a in x]) > x=map(pr, reduce(cross,

Re: yet another noob question

2006-08-14 Thread Jason Nordwick
Somehow my other response to the list got lost. I'm still learning Python, but this seems much better than my first attempt: def pr(x): print x def cross(x,y): return [a+b for a in x for b in y] x=map(pr, reduce(cross, [map(str,range(1,6))]*5)) -j Stargaming wrote: > Jason Nordwick

Re: yet another noob question

2006-08-14 Thread Jason Nordwick
Stargaming wrote: > > Also note that reduce will be removed in Python 3000. What will replace it? -j -- http://mail.python.org/mailman/listinfo/python-list

Re: yet another noob question

2006-08-14 Thread Jason Nordwick
opadd(v): sum = 0 for x in v: sum = add(sum, x) return sum (Yes, I know there are better ways to sum up a list, but I just wanted to test the performance of the loop against reduce. In most of my reduce usages, the function passed to reduce is much mor

Re: yet another noob question

2006-08-15 Thread Jason Nordwick
t timing reduce against a hand coded loop, but instead the operator '+' against the function add, as the function symbol lookup and call seem to have a heavy price. Reduce was one of the nice ways to eliminate some of those lookups. -j [EMAIL PROTECTED] wrote: > Jason N

Re: yet another noob question

2006-08-15 Thread Jason Nordwick
(joins are merely indexes into other structures). -j Steve Holden wrote: > Jason Nordwick wrote: >> I use reduce to also do indexing, hashing with upsert semantics of lists of >> key-value pairs, transitioning through a state table, etc... >> >> Somebody else poin

getting database column names from query

2006-08-16 Thread Jason Nordwick
I'm using MySQLdb and can connect and issue queries that return result sets, but I how do I get the column names for those result sets? >>> c = MySQLdb.connect(*creds) >>> k = c.cursor() >>> k.execute("select * from account") 3L >>> k.fetchall() ((1L, 'test', -1L), (2L, 'Test', -1L), (3L, 'Test2'

setting a breakpoint in the function of my module

2006-08-23 Thread Jason Jiang
all aFunc(), 'c' to it, then 's' to step in, then set the breakpoint inside aFunc() by 'b lineNumber'. It's too cumbersome. Thanks. Jason -- http://mail.python.org/mailman/listinfo/python-list

setting a breakpoint in the module

2006-08-23 Thread Jason Jiang
Func(), 'c' to it, then 's' to step in, then set the breakpoint inside aFunc() by 'b lineNumber'. It's too cumbersome. Thanks. Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: setting a breakpoint in the module

2006-08-23 Thread Jason Jiang
I'm using Python pdb module pdb.py. "Simon Forman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jason Jiang wrote: >> Hi, >> >> I have two modules: a.py and b.py. In a.py, I have a function called >> aFunc(). I'm calling aFu

Re: setting a breakpoint in the module

2006-08-23 Thread Jason Jiang
Great! It's working now. Thank you so much. Jason "Simon Forman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jason Jiang wrote: >> "Simon Forman" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >

how to get file name of the running .py file

2006-08-23 Thread Jason Jiang
Hi, How to get the name of the running .py file like the macro _FILE_ in C? Thanks. Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get file name of the running .py file

2006-08-23 Thread Jason Jiang
Thank you guys. Jason "Simon Forman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Larry Bates wrote: >> Jason Jiang wrote: >> > Hi, >> > >> > How to get the name of the running .py file like the macro _FILE_ in C? >

Python editor

2006-08-24 Thread Jason Jiang
Hi, Could someone recommend a good Python editor? Thanks. Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: Python editor

2006-08-24 Thread Jason Jiang
Thanks Simon. I finally picked SciTE. No time to do further investigation. Jason "Simon Forman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jason Jiang wrote: >> Hi, >> >> Could someone recommend a good Python editor? Thanks. >> &

Re: Newbie - ? get IDLE going on cygwin

2006-09-13 Thread Jason Tishler
e system: 1. shutdown all Cygwin processes and services 2. start ash (do not use bash or rxvt) 3. execute /bin/rebaseall (in the ash window) BTW, idle has problems running under Cygwin Python: http://sf.net/tracker/?func=detail&atid=105470&aid=786827&group

Re: Newbie - ? get IDLE going on cygwin

2006-09-13 Thread Jason Tishler
Dave, On Wed, Sep 13, 2006 at 03:33:01PM +, David J. Braden wrote: > I can now confirm that, yes, IDLE pops up w/o menus under cygwin. You should be able to workaround this problem by executing idle with the "-n" option: $ idle -n Jason -- PGP/GPG Key: http://www.tish

No module named _db2

2006-12-04 Thread jason . meiers
For some reason the _db2 module cannot be imported. Have you had this issue before? [EMAIL PROTECTED] python test_basic.py Traceback (most recent call last): File "test_basic.py", line 2, in ? import DB2 File "/home/itmuser/scripts/lib/PyDB2-1.1.0/test/DB2.py", line 10, in ? import _d

Re: Extract contents of html cells

2006-02-04 Thread Jason Earl
es, tutorials, advice? The tricky bit is parsing HTML. Chances are good that what you want for that is BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/ Take a look at the examples there and then feel free to ask more questions. Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: HTML page into a string

2006-02-07 Thread Jason Earl
u wish to prettify cnn's html, but it should get you to the point where BeautifulSoup's documentation starts to make sense. Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: spell check code

2006-02-09 Thread Jason Earl
rtilley <[EMAIL PROTECTED]> writes: > What is the most common way to spell check comments in code? Are > there any idle plugins or modules that do this? In Emacs you can use "flyspell-prog-mode" to check strings and comments automagically. Just a bit of editor elit

Re: Cygwin IDLE has no menu bar

2006-02-14 Thread Jason Tishler
Steve, On Mon, Feb 13, 2006 at 11:14:03PM -0500, Steve Holden wrote: > I just wondered whether anyone has seen this problem: Yes, this is a known problem: http://sf.net/tracker/?func=detail&atid=105470&aid=786827&group_id=5470 > and fixed it. Unfortunately, no. Jaso

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