|
Oh hey the BSD DB lib is getting axed in 3.0... Did anyone ever actually use that thing for anything? I'd of thought that SQLlite has been the flat file db of choice for a while now
|
# ¿ Oct 2, 2008 16:45 |
|
|
# ¿ May 11, 2024 10:29 |
|
My head hurts. What the hell were apple thinking even CONTEMPLATING distributing python without loving database bindings. Without the db bindings, almost the entire spectrum of useful things to do with scripting languages is left a flibbering mess. Lazy Apple. Lazy loving lazy. Anyone know a good way of getting mysqldb of some variety working on the mac. This is making me too angry working it out for myself
|
# ¿ Oct 7, 2008 19:09 |
|
m0nk3yz posted:Apple doesn't distribute mysql - why would they give you bindings, especially given those bindings compile against a particular version of MySQL that's local to the machine? I'd argue however that Mysql is fundamental enough that apple ought be providing its own package of that as well, or at least providing bindings against the mysql downloadable from the mysql site. Because could you imagine distributing a python app for , say cocoa, that had to do mysql or postgres work? At least with windows, you have mysql.dll or whatever it is, and it all seems to magically kinda work.
|
# ¿ Oct 8, 2008 13:31 |
|
m0nk3yz posted:FWIW, I chucked another side project up on pypi today: woo testbutler looks nice.
|
# ¿ Oct 12, 2008 12:54 |
|
Trying to get Python Imaging Library working with python on Os/X has got me very loving close to just abandoning developing on macs It shouldnt be this hard, but it is, and the fact that Apples primitive-rear end packaging system (there isnt one) is somewhere around "Slackware in the early 90s" doesnt help at all. Everything on google says to either use fink or macpython. no no no no no I'm not using THAT python, I want to use THIS python that came with it. Argh. Come on Apple, just put one staffer onto maintaining your python distro. Its all it will take! You cant just throw products out the door pre-abandoned. </rant> Seriously Apple should just annoint APT-GET or portage or something and provide official distros of stuff like mysql and the python libs and poo poo, so this primitive rear end nonsense of having to hand patch poo poo all the time to get it to compile is history. God forbid someone wanting to run a mac as a server, and having to deal with security updates to open source software.
|
# ¿ Oct 16, 2008 12:32 |
|
SlightlyMadman posted:I'll definitely have te defer to you there, since I come from much more of a heavy-handed java background. The reason I pointed it out is that it avoids magic strings, and if he ever adds more fields to the object he doesn't have to make the change in two places. It avoids magic strings, but endangers the whole operation of magic variables. Theres a lot of __crufty__ __magical__ __stuff__ __under__ __the__ __hood__ that could get caught up in that blender!
|
# ¿ Oct 24, 2008 09:29 |
|
Sparta posted:Apologies if this has been answered already, but there's a lot here to wade through. The tutorial is always the place to start for python. The one on the site is actually very good. It wont take you more than a day, and you'll get quite deep into pythonn, certainly enough to fend for yourself assuming a basic programing competency (which you have if you can do C) The object oriented stuff, uh I dunno man, just think of them as structs with functions inside them, if the analogy of 'balls of data and code that send messages to each other' hurts the head too much. The structs with functions inside them is a bit of a cheap description because it doesnt capture the capacities, but its a start. OO almost always comes to people in one big "ah ha!" moment when suddenly they just 'get it' all at once, a bit like how database normalisation starts off frusturatingly wierd, and then suddenly just makes sense to people in one hit.
|
# ¿ Oct 24, 2008 09:33 |
|
Yeah whats happening is your pointing room1 and room2 at the same class by pointer its sort of saying room1 IS room room2 ALSO IS room the problem here is that when you set room2.name, your actually refering to room.name which is the same thing as room1.name this is wrong! What you want is;- room1 IS A room room2 IS ALSO A room to do this you do you do this room1=room() room2=room() Whats happening here is that calling the room object as a function will A) Create a new INSTANCE of the room object B) call the __init__() function of the object (if it has one) and finally C) poo poo out a pointer to the object into your room1 variable kinda Can I also make a suggestion. Rather than Room1 room2 room3 etc Try roomArray={} roomArray[1] = room() roomArray[2] = room() and so on... That way you can go myRoom=roomArray[roomNo] and it'll always return the right room edit: code:
You can have a self representing room, so when you go myRoom.look(), it'll poo poo out a full description of the room, and the doors and everything. Alternatively you can get a bit more MVC, and have a room that contains a MODEL of the room and how it kinda works , but doesnt represent it to the user. thats done by other code (for instance a showRoom(room) function like you have). Theres a few other ways too. Look up "design patterns". Most are loving worthless poo poo java programmers torture themselves with to make up for the languages contortions, but theres a few great ones as well that are worth learning. duck monster fucked around with this message at 21:43 on Nov 2, 2008 |
# ¿ Nov 2, 2008 21:25 |
|
m0nk3yz posted:Oh no guys, I've picked up "Programming Erlang" - I'm going to the dark side shave that beard son
|
# ¿ Nov 2, 2008 21:44 |
|
king_kilr posted:Guys, this: http://github.com/alex/pyelection/tree/master/models.py#L57 is why you shouldn't be using except: pass, because i don't have a loving clue what my own code does, or what the logic is. In a busy workplace most python programers will probably confess to resorting to *occasionally* crash-mode boundary checking to get things done fast, namely something like code:
Everyones been there, but it is considered BAD mojo. What you should be doing is first testing bounds etc , and THEN access stuff. If you must just crash past something , then try and work out in advance what the error is, and learn how to use except to catch *specific* errors.
|
# ¿ Nov 15, 2008 19:38 |
|
ah, its beautiful-soup based webpage scraping. Yeah ok, that poo poo can get very messy and I can relate to 'gently caress it we are going live' motherfucker-style exception handling.
|
# ¿ Nov 15, 2008 19:45 |
|
The Remote Viewer posted:How long will it take me to get to the point where I can create a very basic roguelike in Python, with some minor past experience in programming? spend a shitload of time learning yourselves lists, tuples and dictionaries, and then try and get your OO mojo up. Rogue-likes are probably right up pythons alley.
|
# ¿ Nov 18, 2008 01:56 |
|
MeramJert posted:I decided to finally try out stackless. I wrote a really really insane web-spider for an old job using stackless. loving thing could max out a 20mbit fibrelink instantly. loving crazy-scaling.
|
# ¿ Nov 21, 2008 22:39 |
|
Centipeed posted:I was looking at GUI programming with Python, but I figured I'd just ask here instead of wading around the internet trying to find an answer: Do any of the Python GUI doohickies work in the same way the visual programming languages work, like VB.net and C#? As in, you can just drag and drop GUI components and then put your code in behind the scenes, as it were? Boa constructor is a full blown delphi/vb type system for python. Its a bit undermaintained and has some quirks however. Its a very impressive piece of code and if the guy behind it wasnt so bad at letting other people work with his code, it'd be *the* IDE for python work bar none.
|
# ¿ Dec 28, 2008 18:31 |
|
deimos posted:I am gonna ask the boss for PyCon, and I am pretty sure I am going to go regardless of job paying for it, at the very least for the conference. I know a couple of developers who have decided to give 09 a miss due to the poo poo that went on with the last pycon. Spending $5K+ to fly from australia to go to a conference on the other side of the earth only to have it wrecked by blatant spamming by vendors doesn't endear folks to the organisation of it all.
|
# ¿ Jan 31, 2009 18:46 |
|
Nigel Tufnel posted:Very very new to Python (learnt BASIC way back in the day). I've followed what I can of some tutorials but need answers to the following: Optimally you might use some sort of string interpolation (google it), but perhaps a little more understandably print 'there is' + X + ' or ' + Y Note, you can have type errors with this, so be careful. quote:What code do I need to use to get the strings x and y into my output? print 'this is line 1 with '+variable2 Dont worry about the '\n' with print, because it does it automatically. Theres also the option with print to use commas to separate stuff ie print 'this is line 1 with' , variable1 print 'this is line 1 with' , variable2 and infact that might even be better because its less likely to poo poo itself if you have to mix string and int, although I still think string interpolation is the way to go, however I dont have the time to explain it, so google is your friend.
|
# ¿ Feb 3, 2009 01:23 |
|
Man I'm still fantasizing about doing a hostile takeover of boa constructor. Delphi-for-python (aka boa constructor) really is the greatest thing ever, but the glacial speed combined with a dude who seems alergic to cooperating with people makes me think that motherfucker needs to be forked. Because a well maintained publically loved boa constuctor would be a dominating bulldozer of a linux IDE. If the free pascal guys (Lazarus, its loving amazing) can do it, why the hell cant python get it right.
|
# ¿ May 25, 2009 16:09 |
|
spankweasel posted:Ignore this post newbies. Coding like this will cause you brain damage and make you think like a java programmer. Before long you will be editing XML based configuration files and your wife will leave you and your dog will bite you. Heres the better way of doing it. Class definition. code:
code:
code:
Sorry spankweazle. Dont teach other people bad habits. Also rampant public property useage is sometimes considered bad OO by (non pythonic) puritans (since how do you concieve of it as 'message exchanges' without complete brainhurt), but OO purism is for smalltalk users but this is python and python programmers specialize in silly walks. Essentially the idea is that you (ab)use the class as a implicit struct. Its not true OO, but its a perfectly acceptable use of objects in python world. duck monster fucked around with this message at 19:59 on May 25, 2009 |
# ¿ May 25, 2009 19:48 |
|
Sylink posted:I think of classes as simply collections of functions and variables that are sort of centered around a common purpose , or a library. Kinda. but not quite. This is more a name space than a class, and you can use class singletons as name spaces, kinda. Really the best way to think of objects is as little black box's that represent a particular thing or concept. In effect a tiny self contained program with multiple entry points. The program is defined in the class, and is made active as an object. So a class might be "Employee", and it holds data for a single employee, can save or retrieve itself from a database, and has functions like "Set pay rate". You might then make 20 employee objects, one for each employee, then have another object called "Payroll" which is a singleton that encapsulates a bunch of data about banks and money and poo poo, and perhaps an instance of a "ledger" object. When you want to pay an employee, you might send a message to that employee object something like john.pay_employee(john.weekly_rate) , note that this is a method call, but its best to think of methods as messages sent to that object. This becomes even more explicit (as message sending) in languages like smalltalk and Objective C. So after you send john.pay_employee(john.weekly_rate), the pay_employee method then sends a message to the payroll object, something like payroll.transfer(450.00 , self.account_number , "Weekly pay for John") which means pay john $450 via the enclosed account_number [extracted from my own properties] and put "Weekly pay for john" into the methods. The payrol might then poo poo out a bunch of data over the net to the bank , then send a message to the ledger recording the transaction. Basically this is modelling the ways a real payroll department might do it IRL. The "john" object is a record in a filing cabinet, and the methods are things you can do with the 'john' object. There might also be a payroll clerk, who you ask (call a method) to do the payroll for john, and the payroll clerk then interacts with both the bank and the general ledger (or whatever the gently caress payroll clerks do). So by converting the entities and processes into objects with methods and properties, you convert a physical process into a computer program. Have a study of the way UML works, its a loving great tool for thrashing out OO designs. Once you start programming OO, you can never turn back. Its a loving great methodology.
|
# ¿ May 27, 2009 09:50 |
|
A A 2 3 5 8 K posted:Some sorts of invalid pages. When you have a database of 400,000 links from all different sources you want to parse, you will find much more that can go wrong with HTML than the authors of any of these packages considered. word. I worked at a company that spidered about 300 sites daily and grabbed details of specials and poo poo , reformetted them, added the markup and published it. The thing ran on a cluster of 5 machines each running a python script with about 400 microthreads (using stackless) and all using beautiful soup , and god drat is there some horrifying HTML out there. Also a 400 thread spider can rape almost any given site to a smouldering mess in a fraction of a second. Don't do this, but god drat the structure of that thing was fun to write. The actual scrapers however made me hate my life.
|
# ¿ Jun 10, 2009 10:29 |
|
Zombywuf posted:I actually prefer writing web scrapers to working with Webservice XML APIs. The tag soup HTML madness is usually nicer that APIs that are just some websites data backed with "<xml>" stuck at the front and "</xml>" tacked on the end. All I can say is beautiful soup saved my sanity.
|
# ¿ Jun 13, 2009 17:39 |
|
Foiltha posted:Any suggestions for a free decent UML tool, aimed at Python in particular? Code generation would be a plus. Boa Constructor will generate UML diagrams from code. Dia2Py (or is it Dia2Django) will generate Django models from DIA UML. Which is to say DIA generates pretty cool UML.
|
# ¿ Jun 16, 2009 14:47 |
|
I still draw up little truth tables as soon as a logical operation looks like its going to have more than 3 or 4 terms
|
# ¿ Jun 17, 2009 17:17 |
|
Actually I'd strongly recomend not letting your mysql listen on a public port. Some dudes gunna scan it down and brutalize it. If you must, set up some sort of SSH tunnel or something. Or better still just put the server on the same box as the machine and only accept local connections.
|
# ¿ Jun 21, 2009 10:21 |
|
Im starting to fill with hate and despair about the lovely state of python on the mac compared with linux and windows (where module installation generally 'just works') anyone got any idea how the gently caress to get igraph to install. loving things got me flumoxed. Theres an installer for it on the site, but I think it just goes off and has a beer instead of installing anything
|
# ¿ Jun 21, 2009 13:32 |
|
I think so. Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information.
|
# ¿ Jun 21, 2009 14:38 |
|
m0nk3yz posted:You should see this: Definately on leopard.
|
# ¿ Jun 21, 2009 20:23 |
|
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. Keep on believing bro. Keep on believing. I've seen first hand MySQL databases raped from somewhat determined brute force attacks. And There have been brute forcer distributed worms for MS-SQL leaving me to suspect a MySQL brute worm is a matter of when, not if.
|
# ¿ Jun 21, 2009 20:26 |
|
Janin posted:The first advisory wouldn't be solved by moving MySQL to an internal port, and the second doesn't expose any data. Forcing all requests to a database server through a proxy is just introducing another layer that could, and probably does, contain security vulnerabilities. Any vulnerability exploitable by a logged-in user could be performed just as easily over an SSH tunnel. What. No thats an absurdity. Two iron gates is harder to crack than one, always.
|
# ¿ Jun 21, 2009 20:28 |
|
bitprophet posted:I actually had to lock our network down with a VPN because of SSH bruteforce attacks. Successful ones. Because highly placed nontechnical staff (read: ones I cannot say "no" to) with logins didn't want to use secure passwords. Moral of story: never rely solely on the strength of a single level of password authentication if your user base consists of people who are not you. quote:To ask a Python question: anyone know of any decent "CLI UI" (and not curses-based, I don't think) libraries for Python? I'm thinking of commonish stuff like progress bars, spinners, formatting data into columns, simple "choose option A B or C" menus, and so forth. (I could swear I saw a PyMOTW posting on that last one, but can't find it now. Maybe I should ask Doug...)
|
# ¿ Jun 22, 2009 13:21 |
|
Uh. Old anti spam trick. MTA , when it detects spam ,rather than hanging up it just sits there holding the spammers hand and falls asleep. The old spam bots where pretty much single threaded, so it'd kill it dead. Old web trick that used to work awesome for web spam was to create a gzip file with a html header and 2 gigs of zeros. 2meg file. Hide it on a <div style=display:none> type link and for added measure put it in robots.txt (to filter out good bots like google) and serve it as a gzipped html file. the thing would send the 2meg file, which would unpack inside the bots brain, flooding it with 2 gigabytes worth of zeros. Make sure apache knows not to unpack it under any costs and ONLY serve it if the bot accepts gzip html It does horrifying things to browsers too.
|
# ¿ Jun 22, 2009 15:10 |
|
You can use Django with fastcgi http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ Also if you must do cgi, make sure your setting your headers right.\ But yeah, go get yourself an account with something like slicehost so you can get your setup juuuust right. Your time is more valuable than making GBS threads around with crappy $5 hosts. A non crappy $20 vhost pays itself off in the first hour of saved time.
|
# ¿ Aug 1, 2009 17:45 |
|
quote:"In the current state of affairs and given the plans of the Python maintainers, there will be likely no python2.6 (even as non-default) in squeeze." Yay debian!
|
# ¿ Aug 26, 2009 10:14 |
|
Whats there to say? 2.6 won't be in the next debian.
|
# ¿ Aug 26, 2009 23:16 |
|
HatfulOfHollow posted:And? Well thats poo poo too. Its a problem, because it slows adoption of 2.6/3.0 and that means python devs have to keep supporting legacy code bases, and provides disincentives for people to modernise their code for the superior 2.6/3.0 branches.
|
# ¿ Aug 28, 2009 06:58 |
|
Anybody know how to convince easy_install not to keep loving up installs by sticking -Wno_long_doubles in CFLAGS when its trying to compile poo poo? Its driving me mad, since everything wants to use that flag, but the mac simply doesnt support it., or rather should I say the more recent apple GCC toolchains don't appear to. cc1: error: unrecognized command line option "-Wno-long-double" cc1: error: unrecognized command line option "-Wno-long-double"
|
# ¿ Dec 2, 2009 14:41 |
|
duck monster posted:Anybody know how to convince easy_install not to keep loving up installs by sticking -Wno_long_doubles in CFLAGS when its trying to compile poo poo? *bangs head on wall* Mac support for python STILL sucks. Anybody had any success with easy_install on python in snow leopard or is its interaction with the latest mac GCC considered broken in general? i just can't find any references on the net on tweaking C flags globally for easy install.
|
# ¿ Dec 6, 2009 17:13 |
|
Milde posted:Sounds like either his distribution of Python is built incorrectly, or the app he's trying to build is adding those flags itself. afaik its just bog standard apple python on a pretty standard snow leopard install mindyou theres been many iiterations of Xcode on there, so gently caress knows what impact that has.
|
# ¿ Dec 6, 2009 21:57 |
|
Sailor_Spoon posted:well --cflags gives me this on the default Snow Leopard python install: code:
How would I give it a kick in the teeth and tell it to use the proper version?
|
# ¿ Dec 7, 2009 03:38 |
|
|
# ¿ May 11, 2024 10:29 |
|
Found it. There was some poo poo stuck in my .profile (or whatever it is again) that was locking it down to the apple 2.5 instead of 2.6. Removed that and victory ensured. Still a little puzzling why apples 2.5 python has GCC options that are not compatible with its prefered GCC. Maybe it didn't upgrade it from leopard when I upgraded, maybe due to some dumb poo poo.
|
# ¿ Dec 8, 2009 06:59 |