Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
ATLbeer
Sep 26, 2004
Über nerd
This might warrant it's own thread but, I'm having problems with both Python24 and 25 installed on my Mac.

I don't particularly remember installing 25 but, I guess it might have come from my Leopard upgrade. I don't honestly care much which version I am using but, my problem comes from the fact that any type of library or module install I am doing is defaulting into the 2.5 installation directory but, all my scripts are executed by 2.4.4.

Can anyone help me sort out this all?

Should I remove one installation (24 or 25) or how can I at least just get easy_install etc, to use one installation (preferably 24, since I already have a bunch of packages installed there) or migrate my packages over?

I'm a bit dumbfounded right now

Adbot
ADBOT LOVES YOU

ATLbeer
Sep 26, 2004
Über nerd

outlier posted:

No need to remove one or the other - they can co-exist nicely. And some software *cough*Zope*cough* can't use 2.5.

It's odd about the install and execution going to different pythons. Type in "which python" at the terminal to see what your default Python is. (I'm guessing 2.5.) Do you have any execution line at the top of your scripts like "#/usr/bin/python24"? Finally, is there an alias or symbolic link to python anywhere that you might have made?

Thanks for the reply. I figured out the problem. I had installed MacPorts and it had put an ugly 2.4.4 version on top of 2.4 and 2.5 and injected itself into my profile. Took MacPorts out and it went back to normal again

Thanks though

ATLbeer
Sep 26, 2004
Über nerd
Python GUI's?

Any opinions?

Tkinter, Wx, GTK, QT?

Which one has better IDE support currently? Are there any good IDE's?

Anyone in particular I should avoid if I'm using OS X?

ATLbeer
Sep 26, 2004
Über nerd

politicorific posted:

here's an easy one hopefully.
let's say I have a bunch of different strings stored in class "Shop"
so that Shop.a = "string", Shop.b = "strang", Shop.c = "streng", ect...

now I want to remove a number of characters from those strings and replace them. First I try writing a function:
code:
def remove(x):
    x=x.split('i')  #'i' represents a unicode string
    x=''.join(x)
    return x
but if I run remove(Shop.a) it doesn't store the output to Shop.a, x is treated as a local variable.

Am I doing this wrong? Should I define this function within the "Shop" class?

The next thing that's bothering me, I don't want to have to write
code:
 remove(Shop.a)
remove(Shop.b)
remove(Shop.c)
remove(Shop.d)
...
can I define a list and then use a "for" command save my wrists?
As mentioned above your data structure isn't quite right for this type of application

I'm just typing this out and not double checking my code so there maybe a syntax error or two in here so YMMV

code:
def remove(x):
    x = x.split('i')
    x = "".join(x)
    return x
Shops = []
Shops.append('string')
Shops.append('strung')
Shops.append('lokiee')

temp = []
for a_shop in Shops:
    temp.append(remove(a_shop))

Shops = temp

ATLbeer
Sep 26, 2004
Über nerd
Did anyone else know that they could write applications for their Nokia phone in pure Python?

I sure as hell didn't

http://opensource.nokia.com/projects/pythonfors60/

I need to dig out my discarded N-Series and play with this.

ATLbeer
Sep 26, 2004
Über nerd
I'm working with a project where I want to override the default set/get methods of an object since I need to do some funky stuff with them while they are being used but, keeping the external interfaces easy to use by using the standard access methods. The way I believe I override the methods doesn't seem to be working...

What am I doing wrong here

code:
class RemoteObj(object):
	code	= "" 
	args	= []
	def __get__(self, obj, typ=None): 
		print "KIIIIIIIIKK"

	def __set__(self, obj, val): 
		print "AHHHHHHH"

	def __delete__(self, obj): 
		pass
	
k = RemoteObj()
k.code = "why is this not hitting the __set__ or __get__ methods"
print k.code
code:
$ python remote_objects.py
why is this not hitting the __set__ or __get__ methods
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin


edit: The output I would expect from the above code would be

AHHHHHHH
KIIIIIIIIIK
why is this not hitting the __set__ or __get__ methods


since the "AHHH" would be printed when the __set__ method would be invoked then the __get__ method would be invoked on access then printed (maybe... I think I need some caffeine here. Well... The value I assigned to code probably wouldn't be printed since I didn't properly replace the __set__ or __get__ methods to actually store the value but, first things first. I'm not even overriding them properly yet.


I'm a moron since in >2.2 python it's now __getattr__ and __setattr__ instead of __get__ __set__

move along

ATLbeer fucked around with this message at 20:13 on Jun 23, 2008

ATLbeer
Sep 26, 2004
Über nerd

Bonus posted:

Yeah. Also watch that you don't fall into an infinite loop within the __getattr__ or __setattr__ methods. Manipulate the __dict__ directly.

Yeah, I learned that pretty quickly. Still can't seem to get the __getattr__ to overload properly here

code:
class RemoteObj(object):
	def __getattr__(self, obj):
		print "GETTING"
		return self.__dict__[obj]

	def __setattr__(self, obj, val): 
		print "SETTING"
		self.__dict__[obj] = val

	code	= "" 
	args	= []
	
k = RemoteObj()
k.code = "why is this not hitting the __getattr__ method"
k.boo = "yo yo"
print k.code
output
code:
$ python remote_objects.py
SETTING
SETTING
why is this not hitting the  __get__ method



Latest version of this mess...

code:
cclass RemoteObj(object):
	def __getattribute__(self, obj):
		print "GETTING", obj
		return object.__getattribute__(self, obj)

	def __setattr__(self, obj, val): 
		print "SETTING", obj, val
		self.__dict__[obj] = val

	code	= "" 
	args	= []
	
k = RemoteObj()
k.code = "why is this not hitting the or __get__ method"
print k.code
Output:
code:
$$ python remote_objects.py
SETTING code why is this not hitting the or __get__ method
GETTING __dict__
GETTING code
why is this not hitting the or __get__ method

After all of this, I've almost forgetting what I was trying to do here... :(

What is with that second invocation of the __getattribute__ method using the __dict__ object? Where is that call coming from? (Never mind... It's me with the self.get call. But, that doesn't make sense. I'm calling object.__getattribute__ not self.__getattribute__. If I really was invoking my method again I would be stuck in a recursion loop. Wth?

ATLbeer fucked around with this message at 21:05 on Jun 23, 2008

ATLbeer
Sep 26, 2004
Über nerd

Bonus posted:

Milde: Ah, yeah, right, I always consfuse get/setattr with get/setattribute. Those are really awkward names.

HatfulOfHollow: try timestamp = oracle.Timestamp(*date). You can also call keyword arguments in that way by using ** with any dict-like object.

e: beaten :pwn:

Can someone show me the Python docs on the *array, **array information? I know what it does but, I've never actually seen the docs for it. It's also hard to google "python *" :(

ATLbeer
Sep 26, 2004
Über nerd
Here's an oddity I can't seem to figure out. I have a list of objects that I can interate through but, how to I operate on them?

This is a very simplistic example but, demonstrates what I want
code:
k = [1,2,3,4,5,6,7]
for i in k:
 i = 0
How do I set all the elements in k to 0 by interating through the objects?

Caveat: without the obvious iterating via Index. I want to maintain using it by objects? Is that possible or do I have to use indices?

Not*
for x in range(len(k)):
k[x] = 0

ATLbeer fucked around with this message at 00:24 on Jul 1, 2008

ATLbeer
Sep 26, 2004
Über nerd
Well.. I guess I should have used my complete example. Simplifying it kind of changes the complexity.

This is my current function.

code:
def clense_table(table):
	for x in range(len(table)):
		try:
			for y in range(len(table[x])):
				table[x][y] = clense_cell(table[x][y])
		except:
			pass
	return table
(*Fixed a bug of omission... len(x) should have been len(table[x]) .. see... too complex :v:)
It's a multi-dimensional table of unknown dimensions and each cell needs to be slightly massaged to eliminate some unneeded cruft

I would rather
code:
def clense_table(table):
 for row in table:
  for cell in row:
   cell = clense_cell(cell)
That's obviously a lot more elegant and easier to read.

ATLbeer fucked around with this message at 00:33 on Jul 1, 2008

ATLbeer
Sep 26, 2004
Über nerd

Bonus posted:

Watch out .... in your first example, you're modifying the arguments in place and then returning a copy. So if someone passes a list to that function and tries to use the same list later on, they'll find it's been mysteriously changed.
Why not just do
code:
def cleanse_table(table):
  return [[cleanse_cell(cell) for cell in row] for row in table]

Can I get the Python man pages that explain that syntax :downs:

ATLbeer
Sep 26, 2004
Über nerd

Bonus posted:

Sure, it's section 5.1.4 here http://docs.python.org/tut/node7.html

It's quite simple actually, this is how list comprehensions behave:
code:
>>> foo = [1,2,3,4,5]
>>> [x*2 for x in foo]
[2, 4, 6, 8, 10]
>>> [x/2 for x in foo if x % 2 == 0]
[1, 2]
>>> strings = ['hehe', 'woot', what']
>>> [st.upper() for st in strings]
['HEHE', 'WOOT', 'WHAT']
That is one of those reasons why Python is so much fun to work with. When I was learning Python I was insanely happy to discover list.sort(func). So elegant

Are there enough of these for a Python tips and tricks thread?

ATLbeer
Sep 26, 2004
Über nerd
What the hell is going on here
code:

class MenuItem:
	def __init__(self, Text = "", URL="", Current=False):
		self.Text = ""
		self.URL = ""
		self.Current = False
class PageMenu:
	def __init__(self, Enabled=False, Items=[]):
		self.Enabled = False
		self.Items = []
class MenuContainer:
	sidemenu	= PageMenu()
	midmenu		= PageMenu()
	topmenu		= PageMenu()
	footer		= PageMenu()
	def __init__(self, Settings = None):
		self.midmenu.Items.append(MenuItem(Text="Home", URL="/"))
		self.midmenu.Items.append(MenuItem(Text="Builder", URL="/builder/"))
		self.midmenu.Items.append(MenuItem(Text="Prices", URL="/prices/"))
		self.midmenu.Enabled = True
		
for x in range(1, 5):
	m = MenuContainer()
	print len(m.midmenu.Items)
Output:
3
6
9
12

So why is this happening? I thought every time I call m=MenuContainer() it creates a new MenuContainer object and assigns it to m? Why is it the same object over and over again?

ATLbeer
Sep 26, 2004
Über nerd

deimos posted:

def __init__(self, Enabled=False, Items=[]):

That line, change it to Items=None then
code:
if not Items:
    Items=[]
You have to remember that def is a keyword that creates a function object.

Didn't make a difference

ATLbeer
Sep 26, 2004
Über nerd

JoeNotCharles posted:

This creates sidemenu, midmenu, topmenu and footer as class variables. All instances of MenuContainer will share them. You want

code:
class MenuContainer:
  def __init__(self, Settings = None):
    self.sidemenu = PageMenu()
    self.sidemenu.Items.append(MenuItem(Text="Home", URL="/"))
    ...

That was it... Working 12 hours today and my brain is fried... I need to blow something up tomorrow.

ATLbeer
Sep 26, 2004
Über nerd

Hanpan posted:

Wow. After being recommended pyGame over in the Game Development thread, I have been trying to figure out how to get python / pygame and setup with a decent IDE on Mac OSX.

Can anyone point me in the direction of a simple step by step tutorial to getting things up and running? All the stuff on the pygame website is pretty advanced.

I always check PythonMac for packages first when installing a big package. These are nice tested pkg installers for OS X that have always worked goldenly for me. PyGame is included there

http://pythonmac.org/packages/py24-fat/index.html

ATLbeer
Sep 26, 2004
Über nerd
I have an odd problem. I have a RPC that is returning a dictionary but, unfortunately the dictionary is coming back as a string. It's a valid dictionary but, basically the __str__ version of the dict.

How can I cast the string back into a dictionary :\

ATLbeer
Sep 26, 2004
Über nerd

Scaevolus posted:

I can't think of anything other than eval() or a similarly hacked-up parser :/

I guess that technically works

ATLbeer
Sep 26, 2004
Über nerd
Has anyone had a good experience with a messaging package?

I have used the XMLRPC library and I LOVE it.. I really want to use the library but, I would like some sort of central logging of all messages that have gone through the system for debugging and error checking since it's going to be transactional system. I guess I could funnel all the XMLRPC requests through a handler which would log the message and pass it along to the appropriate system but, that seems like a cheap hack and a bottle neck.

A Jabber server seems like the only solution but, I can't seem to bring my self to be a fan of the libraries out there. They all seem to be a bit too "un-pythonic" and obtuse.

Anyone have any experience in a client-server-client messaging system for Python that you've liked to work with or do you believe I'm just stuck hacking up a Pythonic wrapper for an existing Jabber wrapper?

ATLbeer
Sep 26, 2004
Über nerd
Retarded question but, I just can't seem to find the right words to Google for.

I have a list that I want to iterate over the list and run the same function against all the items in the list in place.

I know there is a shortcut here but, my brain isn't working properly right now

ATLbeer
Sep 26, 2004
Über nerd
Treading into a territory I've never been in and am having a hard time Googling up what I need here.

I'm trying to 'monitor' the real-time quote information from Yahoo Finance and they have quite a clever system of getting to the browser.

So if you go here: http://finance.yahoo.com/q?s=wb

(If it's during US market hours) You'll notice the prices update in 'real-time' and not on a constant polling basis. This is because Yahoo is pushing the data to the page with a LONG open HTTP connection that is connected to a push (maybe Comet) server.

Here's the URL to the connection
long url

Watching Firebug it looks like Yahoo's push server occasionally sends down the updates and the JS on the page handles the rest. How do I hold open this HTTP connection and use the data coming down the pipe here?

ATLbeer fucked around with this message at 17:13 on Sep 18, 2008

ATLbeer
Sep 26, 2004
Über nerd
I have a huge array (400k+) of dicts that I'm trying to work with without iterating over the list multiple times since it's a time-sensitive execution. I'm trying to just break out the value of the dictionary back into the array.

[{'DxY': 17L}, {'DxY': 9L}, {'DxY': 8L}, ............ {'DxY': 7L}, {'DxY': 6L}, {'DxY': 4L}]

What I want is [17L, 9L, 8L, ..........., 7L, 6L, 4L] but, without having to do something like
code:
new_array = []
for x in big_list:
    new_array.append(x['DxY'])
Well.. I should probably tack on what I need as an end result since there might be a way to do it without constructing new data structures on the fly here.

The list I'm receiving is already sorted and I'm trying to find out what position a new integer would be in the list. I don't need to insert it just identify the position. I was planning on using bisect to identify the position in the array since it's a pretty optimized function

ATLbeer fucked around with this message at 16:09 on Oct 2, 2008

ATLbeer
Sep 26, 2004
Über nerd

Bonus posted:

Use generators! (What a surprise! :v: )
code:
>>> big_list = [{'DxY':17L}, {'DxY':9L}, {'DxY':199L}]
>>> new_list_gen = (a['DxY'] for a in big_list)
Then you can iterate over new_list_gen. No new copies of big_list are created.

Grr... I always forget about generators. I need to just write a few hundred and play with them so they get stuck in my head.

Unfortunately in this case (I updated my OP) I don't know if a generator is going to be the best solution since I don't need (or really want) to iterate over the list I need to search through the list.

Or do I need to get another coffee?

vvv I'm not storing them that way. I'm just getting them that way. I'm looking at trying to solve it upstream

ATLbeer fucked around with this message at 16:43 on Oct 2, 2008

ATLbeer
Sep 26, 2004
Über nerd

Bonus posted:

Use generators! (What a surprise! :v: )
code:
>>> big_list = [{'DxY':17L}, {'DxY':9L}, {'DxY':199L}]
>>> new_list_gen = (a['DxY'] for a in big_list)
Then you can iterate over new_list_gen. No new copies of big_list are created.

4x factor improvement... I'm def going to start practicing generators

ATLbeer
Sep 26, 2004
Über nerd

m0nk3yz posted:

Oh no guys, I've picked up "Programming Erlang" - I'm going to the dark side :jihad:

Of course, this is all part of my clever plot to introduce Actors/Message passing pieces to python.

code:
1> X = 6.
6
2> X = 7.
** exception error: no match of right hand side value 7
Erlang is another planet

ATLbeer
Sep 26, 2004
Über nerd
So... This may go in the Mac thread but, it's a Python specific problem

I just got a new Mac and when I enter into the Python shell I can't use the Up/Down/Left/Right arrows. For example... This is what happens when i push the up button

code:
>>> ^[[A
Left arrow

code:
>>> ^[[D
Etc...

Help me!

ATLbeer
Sep 26, 2004
Über nerd
Anyone know a module that does MIME decoding for email?

I'm working on an app that is reading messages from a POP3 server and just need the from address, subject, and body of the message. Unfortunately email I've found some email clients (Blackberries, Outlook) do loving horrible things to email. I just need a way to reliably extract plain text from the email.

ATLbeer
Sep 26, 2004
Über nerd

No Safe Word posted:

Does the one that comes in the standard lib not cut it? Or was it just overlooked?

It didn't cut it for some reason. Maybe I was misusing it but, it for some cases (BB email in particular) would just pass back the plain encoded text.

I'm using poplib to retrieve the email and tried passing it to the email lib. Maybe I'm just using it wrong.

ATLbeer
Sep 26, 2004
Über nerd

chemosh6969 posted:

I'm not 100% sure, but I was doing a similar thing and asked a question here and I may have pasted the code I was trying.

If not, I'll link to the guide I was working off of.

My problem was the body of the email. I could get it but it was one big blob that I couldn't do anything with. I couldn't get a single word out of the thing. I tried converting it to strings, using indexes, and other stuff I can't remember and I couldn't get anywhere with that thing.

The entire thing would shoot out of whatever blender I was trying to chop it up in and then it would laugh at me.

If you're able to do anything with the body you're getting, could show me how you did it?

This is the exact problem I'm having :(

ATLbeer
Sep 26, 2004
Über nerd

nbv4 posted:

In Django, you can format dates in the template system by using PHP-style date format strings like so: "{{ my_date|"n-j-Y" }}" but how do you do the same thing from within python itself? I know about datetime.date.strftime() and strptime(), but those functions take a completely different date formatting "language"...

When in doubt... browse source :v:

http://code.djangoproject.com/browser/django/trunk/django/utils/dateformat.py

code:
"""
2	PHP date() style date formatting
3	See [url]http://www.php.net/date[/url] for format strings
4	
5	Usage:
6	>>> import datetime
7	>>> d = datetime.datetime.now()
8	>>> df = DateFormat(d)
9	>>> print df.format('jS F Y H:i')
10	7th October 2003 11:39
11	>>>
12	"""

ATLbeer
Sep 26, 2004
Über nerd

wrok posted:

code:
>>> new_word = "print(new_word)"
>>> eval("".join([x[0] for x in [[x,print(x)] for x in new_word]]))

3.0 snob... 2.6 fo lyfe

This is hysterical code though.. Reminded me about a turned down consulting gig back in my PHP days where there were "stored procedures" of code that were stored as text in a DB which was called and eval()'d. I couldn't find anywhere in the code where the stored data ("function") was altered.. The originally programmer just used the DB to store code as opposed to just creating a new file. It was more than I wanted to try to peel apart for what they were willing to spend.

ATLbeer
Sep 26, 2004
Über nerd

m0nk3yz posted:

Reminds me of another weird urge I had the other day; given stackless tasklets are picklable (as well as the channel), you could serialize them and put them into a database, and in theory, a SQL query of the objects in the database could actually dictate the "program structure". You just need an ORM that auto-depickles the objects and adds them to the scheduler. Store your channels in another table, and select those with the query too.

Yeah, no.

I had a similar thought a while ago (and I wasn't the first one, there are modules out there that people have written already for it) to pickle python functions and send them over the wire with parameters to "workers" to have a distributed work farm in processing large amounts of information. I don't recall what the modules that actually did it were called as my need for such a system disappeared. But, you can do all sorts of fun things with that type of "meta" Python

ATLbeer
Sep 26, 2004
Über nerd

king_kilr posted:

For those doing concurrency stuff I implemented futures in Python earlier today for those who may be interested: http://dpaste.com/11007/

So quick question on program flow here

code:
g = Thread(f, args=(1,)).run()
h = Thread(f, args=(2,)).run()
print h + 3
print h
Obviously thread g and h both are running concurrently but, why doesn't Python throw a name error when referencing h in line 3. It obviously is waiting for thread h to return the value to h but, how does Python know to "wait" for h to have a value before evaluating that statement. There doesn't appear to be a control structure to stop that evaluation from happening?

edit: It's late and I'm tired... So in case my question doesn't make sense... Why isn't it written like this
code:
h = None
h = Thread(f, args=(2,)).run()
while h is None:
 pass
print h+3
Obviously this example defeats the purpose of concurrency but, I'm confused as to why (or how) Python knows to wait or ignore the next statement till the previous thread is finished without the "while h is None"

ATLbeer fucked around with this message at 06:25 on Mar 10, 2009

ATLbeer
Sep 26, 2004
Über nerd
On the hunt for a Python package before I go reinvent the wheel

I'm looking for a PubSub style messaging system that I can pass objects (like in Pyro) for the messages

I basically have a process that is monitoring a data feed (IRC channel) and I need the resulting parsed data to be sent to any application that "subscribes" to the data feed. This data is real time data so a polling system is unusable and I'd like to be able to attach different applications to this data stream.

ATLbeer
Sep 26, 2004
Über nerd

m0nk3yz posted:

This is similar to a JavaSpace/JMS (for Java) - Off the top of my head, does then Event server stuff in pyro get you close to what you want? http://pyro.sourceforge.net/manual/6-eventserver.html

Otherwise, I got nothin - all the message-queue stuff out lately is cross language and polling based. I just had some thoughts about writing one in cython that just shot pickled objects around.

Eh... I haven't touched Java in years and wanted a pure Python solution. I have a bit more work on some other stuff. If there isn't anything out there I just write my own. Publishing pickled objects is basically what I'm looking for.

Now that I read your link... I might play with that for a while this weekend

ATLbeer
Sep 26, 2004
Über nerd

Zombywuf posted:

Where did you find that number? Their benchmark page appears devoid of benchmarks.

http://code.google.com/p/unladen-swallow/wiki/Releases

code:
2to3:
Min: 22.888 -> 20.299: 12.75% faster
Avg: 22.926 -> 20.329: 12.77% faster
Significant (t=145.835478, a=0.95)

Django:
Min: 0.596 -> 0.554: 7.52% faster
Avg: 0.598 -> 0.557: 7.43% faster
Significant (t=297.475166, a=0.95)

Pickle (complex):
Min: 1.023 -> 0.409: 150.36% faster
Avg: 1.053 -> 0.410: 157.17% faster
Significant (t=1102.029662, a=0.95)

Pickle (simple):
Min: 1.223 -> 0.868: 40.83% faster
Avg: 1.229 -> 0.876: 40.20% faster
Significant (t=695.483070, a=0.95)

PyBench:
Min: 46961 -> 38795: 21.05% faster
Avg: 47775 -> 39635: 20.54% faster

SlowPickle:
Min: 1.236 -> 1.072: 15.22% faster
Avg: 1.239 -> 1.076: 15.17% faster
Significant (t=497.615245, a=0.95)

SlowSpitfire:
Min: 0.762 -> 0.670: 13.87% faster
Avg: 0.764 -> 0.671: 13.80% faster
Significant (t=452.978688, a=0.95)

SlowUnpickle:
Min: 0.606 -> 0.528: 14.63% faster
Avg: 0.607 -> 0.530: 14.60% faster
Significant (t=581.549445, a=0.95)

Unpickle (complex):
Min: 0.738 -> 0.536: 37.71% faster
Avg: 0.746 -> 0.547: 36.24% faster
Significant (t=122.112665, a=0.95)

Unpickle (simple):
Min: 0.756 -> 0.486: 55.60% faster
Avg: 0.774 -> 0.493: 56.91% faster
Significant (t=331.578243, a=0.95)

ATLbeer
Sep 26, 2004
Über nerd

Avenging Dentist posted:

code:
>>> import numpy
>>> f = numpy.array([1,2,3,4,5,6,7,8,9])
>>> f
array([1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> f[f>5]
array([6, 7, 8, 9])

wow.... i had no idea you could do that...

insanity and very powerful

ATLbeer
Sep 26, 2004
Über nerd
Found this useful this week.. Just wanted to share

http://pypi.python.org/pypi/python-daemon

quote:

python-daemon 1.4.5

This library implements the well-behaved daemon specification of PEP 3143, "Standard daemon process library".

A well-behaved Unix daemon process is tricky to get right, but the required steps are much the same for every daemon program. A DaemonContext instance holds the behaviour and configured process environment for the program; use the instance as a context manager to enter a daemon state.

Simple example of usage:

code:
import daemon

from spam import do_main_program

with daemon.DaemonContext():
    do_main_program()

ATLbeer
Sep 26, 2004
Über nerd

dustgun posted:

If I want to make a site that's basically only index.py, what's the best way to do that? I'm honestly not quite sure what magic words I should be searching for.

web.py or for a django related 'micro-framework' djng

Adbot
ADBOT LOVES YOU

ATLbeer
Sep 26, 2004
Über nerd

Janin posted:

What? There's nothing insecure about a public MySQL server. Just use a password other than the combo to your luggage and you'll be fine.

This is wrong. Never leave any service running publicly available unless it has to be accessed by something external. When it does need to be accessed externally enforce the tightest access rules possible on multiple layers when possible. If your backup server needs to get access to your MySQL server and an SSH tunnel or VPN isn't possible 3306 should be explicitly blocked in your firewall from all IPs EXCEPT your backup machine's IP and then the backup user should ONLY be able to connect from that IP.

Never just leave a service running publicly available unless it 100% needs to be

  • Locked thread